Forum Discussion

Paramanand_Ghod's avatar
Paramanand_Ghod
Contributor
15 years ago

How to verify data type of values in response?

In my response there are several different data types. I need to verify the data type of all those values.
for example I have a Int value, Is there any function which will verify that the values u=is integer.


Thanks in Advance,
Param

3 Replies

  • LChristian's avatar
    LChristian
    Occasional Contributor
    Usually type verification is done through schema compliance assertions in soapUI.
    My webservice WSDL has a supporting XSD file with all of the data structures and underlying types, that are contained in the SOAP messages, being well defined.

    Example:

    If I got a response with a body of:
    <Foo>600</Foo>


    then somewhere in my XSD there should be something that says what the restrictions on what can be the value in my Foo element, such as:


    <schema>

    <!-- other stuff... -->

    <simpleType name="Foo">
    <annotation>
    <documentation>
    Bar
    </documentation>
    </annotation>
    <restriction base="decimal">
    <totalDigits value="6"/>
    <fractionDigits value="1"/>
    <minInclusive value="0"/>
    <maxInclusive value="99999.9"/>
    </restriction>
    </simpleType>

    <!-- other stuff... -->

    </schema>


    I've also found Scanner to be a useful class for verify types within strings.
  • Hi,

    Thanks for your reply, it is very useful.

    Is it possible to do the same thing using Groovy scripting?


    Thanks,
    Param
  • LChristian's avatar
    LChristian
    Occasional Contributor
    I only know of that Scanner class for basic verification of primitives. You'd have to dig deeper if you wanted to check things like maximum number of digits, fractional digits, bounds, etc..

    I'm not sure if there is an easy way to access the XSD in scripting or even what kind of interface it would have.. I have only ever needed to verify types in SOAP responses and the schema compliance assertions have worked fine for that.