Arraytype element in custom request body webservice call causes an error

1
I'm calling a webservice with the following custom request body: <ns1:sendmsg xmlns:ns1="http://api.clickatell.com/soap/document_literal/webservice.php"> <session_id>sessionid</session_id> <api_id>3475517</api_id> <user>wverbeek</user> <password>password</password> <to><item>31623350088</item></to> <from></from> <text>test</text> <concat></concat> <deliv_ack></deliv_ack> <callback></callback> <deliv_time></deliv_time> <max_credits></max_credits> <req_feat></req_feat> <queue></queue> <escalate></escalate> <mo></mo> <climsgid></climsgid> <unicode></unicode> <msg_type></msg_type> <udh></udh> <data></data> <validity></validity> </ns1:sendmsg> (the real sessionid and password is hidden for obvious reasons) Using Mendix it creates an error: Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: javax.xml.ws.soap.SOAPFaultException: SOAP-ERROR: Encoding: Violation of encoding rules With SoapUI I can send the following (same) message with good result: <web:sendmsg soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <session_id>sessionid</session_id> <api_id>3475517</api_id> <user>wverbeek</user> <password>password</password> <to><item>31623350088</item></to> <from></from> <text>test</text> <concat></concat> <deliv_ack></deliv_ack> <callback></callback> <deliv_time></deliv_time> <max_credits></max_credits> <req_feat></req_feat> <queue></queue> <escalate></escalate> <mo></mo> <cliMsgId></cliMsgId> <unicode></unicode> <msg_type></msg_type> <udh></udh> <data></data> <validity></validity> </web:sendmsg> The relevant wsdl-part looks like: <xsd:element name="sendmsg"> <xsd:complextype> <xsd:sequence> <xsd:element name="session_id" type="xsd:string" minoccurs="0" maxoccurs="1"/> <xsd:element name="api_id" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="user" type="xsd:string" minoccurs="0" maxoccurs="1"/> <xsd:element name="password" type="xsd:string" minoccurs="0" maxoccurs="1"/> <xsd:element name="text" type="xsd:string" minoccurs="0" maxoccurs="1"/> <xsd:element name="to" type="xsd:string" minoccurs="1" maxoccurs="unbounded"/> <xsd:element name="from" type="xsd:string" minoccurs="0" maxoccurs="1"/> <xsd:element name="concat" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="msg_callback" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="deliv_ack" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="deliv_time" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="max_credits" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="req_feat" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="queue" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="escalate" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="mo" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="climsgid" type="xsd:string" minoccurs="0" maxoccurs="1"/> <xsd:element name="unicode" type="xsd:int" minoccurs="0" maxoccurs="1"/> <xsd:element name="msg_type" type="xsd:string" minoccurs="0" maxoccurs="1"/> <xsd:element name="udh" type="xsd:string" minoccurs="0" maxoccurs="1"/> <xsd:element name="data" type="xsd:string" minoccurs="0" maxoccurs="1"/> <xsd:element name="validity" type="xsd:int" minoccurs="0" maxoccurs="1"/> </xsd:sequence> </xsd:complextype> </xsd:element> The part of the web service call which causes the error mentioned is: <to><item>31623350088</item></to> When I use <to>31623350088</to> (so without the <item>-element) then Mendix gives no longer an error, but this webservice call won't do the job: in SaopUI this webservice call ends with a message 'Invalid Destination Address'. So, at the end of this story, my question is: how do I deal with an array-type element like: <xsd:element name="to" type="xsd:string" minoccurs="1" maxoccurs="unbounded"/> in a custom Request body?
asked
1 answers
1

The XML example you specified does not seem to comply to the XSD, the item element is not specified in the XSD. MaxOccurs="unbounded" means the element itself can occur multiple times, not that it is an array or can contain sub-elements. The correct way to form an XML message for that XSD is indeed without the <item> element. If you want to include multiple "to"s, you can just list them directly after one another:

 <web:sendmsg soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  [...]
 <to>316xxxxxxxx</to>
 <to>316xxxxxxxx</to>
 <to>316xxxxxxxx</to>
 [...]
 </web:sendmsg>

Why this gives you an error in SoapUI is hard to say, since the XML you posted does not look like a complete Soap message (no envelope or body), nor is your WSDL complete. Can you post the entire WSDL and the complete message you are sending?

By the way, I just noticed it is also hard to determine whether the two messages you mention (soapui and mendix) are indeed the same, since the appear to use different namespaces. Again, can you post the full message XML including namespace definitions?

answered