Reputation: 2011
I am trying to use a SOAP api with SOAPUI. The "get" operation described in the WSDL looks like this:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:MarketingCenter" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header/>
<soapenv:Body>
<urn:Get soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<Authentication xsi:type="urn:Authentication">
<!--You may enter the following 6 items in any order-->
<Username xsi:type="xsd:string">myUserName</Username>
<Password xsi:type="xsd:string">mypassword</Password>
<CustomerId xsi:type="xsd:int">29833</CustomerId>
<Level xsi:type="xsd:int">0</Level>
<Source xsi:type="xsd:string">?</Source>
<Options xsi:type="xsd:int">0</Options>
</Authentication>
<Method xsi:type="xsd:string">keyword.list</Method>
<Arguments xsi:type="urn:ArrayOfKeyValuePairs" soapenc:arrayType="urn:KeyValuePair[]"/>
</urn:Get>
</soapenv:Body>
</soapenv:Envelope>
But when ever I run this operation, I get the following error:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns4="urn:MarketingCenter">
<SOAP-ENV:Body>
<ns4:GetResponse>
<return xsi:type="ns4:GetResponseData">
<Data xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[0]" xsi:nil="true"/>
<Status>
<ErrorCode xsi:type="xsd:int">1</ErrorCode>
<ErrorString xsi:type="xsd:string">One or more of the arguments were invalid</ErrorString>
<ErrorDetails xsi:type="xsd:string">One or more of the arguments were invalid</ErrorDetails>
</Status>
</return>
</ns4:GetResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I'm not sure where I should but the list of arguments, or how to format this list. I do realize they want an array of arguments, but where should I put this array? Wherever I was supposed to put in other values there was a '?', so I'm not sure where to input this argumentw array.
Upvotes: 1
Views: 8754
Reputation: 3567
It is expecting you to put in real values here:
<Authentication xsi:type="urn:Authentication">
<!--You may enter the following 6 items in any order-->
<Username xsi:type="xsd:string">myUserName</Username>
<Password xsi:type="xsd:string">mypassword</Password>
<CustomerId xsi:type="xsd:int">29833</CustomerId>
<Level xsi:type="xsd:int">0</Level>
<Source xsi:type="xsd:string">?</Source>
<Options xsi:type="xsd:int">0</Options>
</Authentication>
The list of arguments is just Username
, Password
, CustomerId
, etc. Instead of myUserName
, mypassword
put in whatever the service is expecting.
As far as:
<Arguments xsi:type="urn:ArrayOfKeyValuePairs" soapenc:arrayType="urn:KeyValuePair[]"/>
That would probably look something like:
<urn:Get>
...
<Arguments xsi:type="urn:ArrayOfKeyValuePairs" soapenc:arrayType="urn:KeyValuePair[5]">
<KeyValuePair>
<Key xsi:type="xsd:string">foo</Key>
<Value xsi:type="xsd:string">bar</Value>
</KeyValuePair>
<KeyValuePair>...</KeyValuePair>
<KeyValuePair>...</KeyValuePair>
<KeyValuePair>...</KeyValuePair>
<KeyValuePair>...</KeyValuePair>
</Arguments>
</urn:Get>
Where the contents of depended on how that type is defined by the service (just a <Key>
element and a <Value>
element according to the WSDL). Make sure the number in square brackets ([5]
) matches the number of <KeyValuePair>
elements.
Upvotes: 2