Forum Discussion

giocot's avatar
giocot
New Member
7 years ago

How to set Array parameters

Hi all

i'm try to test a web service that require this parameters:

 

<soapenv:Body>
<urn:getState soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<token xsi:type="xsd:string">?</token>
<id xsi:type="urn:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[]"/>
</urn:getState>
</soapenv:Body>

 

but i don't understand how to set the parameters in this section :
<id xsi:type="urn:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[]"/> 

could some help me 

thanks in avance

i tried with 

<soapenv:Body>
<urn:getState soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<token xsi:type="xsd:string">pktdnwiqjz-knklnjdqqp-exldyapsnh</token>
<id xsi:type="urn:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[2]"/>
<item>xx</item>
<item>aa</item>
</id>
</urn:getState>
</soapenv:Body> 

but i receive:

soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 12; Il tipo di elemento "urn:getState" deve terminare con la corrispondente tag finale "&lt;/urn:getState>".</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">fxxx.com</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>

  • Quick solution:

    <id xsi:type="urn:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[]">ID should go here</id>

     

    Explanation:

    Let's take it apart piece by piece. If I understand correctly, the problem is with the following piece:

     

    <id xsi:type="urn:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[]"/>

     

    In your case 'id' is the xml element which is expected by definition of your webservice. XML elements usually have content wrapped inside them. It is the most obvious and we've seen it all. For example:

     

     

    <id>This sample content</id>

     

    Not uncommon but a little bit more complex is providing content in one or more attributes of respective element. For Example:

     

    <id typeAttribute="Sample content of typeAttribute" anotherAttribute="Sample content of anotherAttribute">This is sample content</id> 

     

    At last we are getting to namespaces. You can see them in bold in your example bellow and they are basically saying attribute 'type' belongs to namespace (you can imagine namespace as a group or collection of elements) called 'xsi'. Attribute 'arrayType' belongs to 'soapenc' namespace. So namespaces are used to describe relation of element or attribute to certain group, which enables you in practice to distinguish among all the elements in xml file and crete pseudogroups for whatever purpose you may have.

     

     

     

    <id xsi:type="urn:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[]"/>

     

    So if we put it all together, in your case here is the explanation for each piece of the problematic line:

    • 'id' is your xml element
    • 'xsi' and 'soapenc' are namespaces of your attributes
    • 'type' and 'arrayType' are attributes of 'id' xml element
    • "urn:ArrayOf_xsd_string" is content of 'type' attribute
    • "xsd:string[]" is content of arrayType attribute