Forum Discussion

commune's avatar
commune
New Contributor
12 years ago

SOAP UI Dynamic Mock response

Hi
I was trying some scripting in Dynamic mock response for some web service request. I got most part of it, however i am stuck with the data type other than String. For example:


I have this in my xsd:


<xs:complexType name="StoreInformation_Type">
<xs:sequence>
<xs:element name="StoreNumber" type="xs:string"/>
<xs:element name="NhinStoreId" type="NhinId_Type"/>
</xs:sequence>
</xs:complexType>

<xs:simpleType name="NhinId_Type">
<xs:restriction base="xs:string">
<xs:annotation>
</xs:annotation>
<xs:pattern value="[0-9]{1,10}"/>
</xs:restriction>
</xs:simpleType>


Now i want to create a mock response :

Something like this

<v41:StoreNumber>${storeId}</v41:StoreNumber>
<v41:NhinStoreId>${NhinStoreId}</v41:NhinStoreId>


for which i get an error as

line 10: string value '${NhinStoreId}}' does not match pattern for NhinId_Type in namespace http://ecc.pdxinc.com/webservice/StoreI ... ice/xsd/v4

and my sample script is

def request = new XmlSlurper().parseText(mockRequest.requestContent);

context.storeId = request.Body.getStoreInformation.StoreInformationRequest.StoreNumber.toString();

context.nhinid = request.Body.getStoreInformation.StoreInformationRequest.NhinStoreId.toString();


if (context.storeId =='114') {
context.storeId ='114';
context.NhinStoreId='9000015';

}


Will really appreciate if someone can anyone help me out with the thing i am missing over here.
No RepliesBe the first to reply