Jump to content
Leo Lui

SOAP client cannot send array to the SOAP server

Recommended Posts

I am writing a SOAP web service client to call a SOAP API in another server. That API needs to pass a 'array of string' type variable into it as a parameter. The code I wrote like this:

 

objectA := mySOAPService.Create;

 

//array of string
Items[0] := 'BR1    X' //<- product code
Items[1] := 'BR2    X'

 

objectA.ItemIds  := Items;  //<- assign the array to a property of the object. The product code list.
result := mySOAP.GetItems(ObjectA)  //<- call the SOAP API function by passing the object to it.

 

But the server always feedback no product code received.

 

I review the SOAPRequest parameter of the  THTTPRIO OnBeforeExecute event. The SOAPrequest parameter shows

 

<?xml version="1.0"?>
<SOAP-ENV:Envelope 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">
<SOAP-ENV:Body>
<GetItems xmlns="http://www.cegid.fr/Retail/1.0">
<Request>
<ItemIds>
<string>BR1                              X</string>
</ItemIds><StoreId>101</StoreId>
</Request><Context><DatabaseId>Y2_C3</DatabaseId>
</Context></GetItems>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

There is no array under the node <ItemIds>. Just a single line, <string>BR1                              X</string>. I copy it to the SOAPUI and run it, it shows the same error message, no product code sending to it.

 

After doing comparison between a workable XML generated by SOAPUI with the one generated by Delphi,
I put a 'xmlns' serialization description to the <GetItems> node. It runs normally in SOAPUI and return correct result.

 

<?xml version="1.0"?>
<SOAP-ENV:Envelope 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">
<SOAP-ENV:Body>
<GetItems xmlns="http://www.cegid.fr/Retail/1.0" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">. //<-- description I added
<Request>
<ItemIds>
<arr:string>BR1                              X</arr:string> //<- add arr:
<arr:string>BR2                              X</arr:string>
</ItemIds><StoreId>101</StoreId>
</Request><Context><DatabaseId>Y2_C3</DatabaseId>
</Context></GetItems>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> 


I believe that Delphi SOAP library may missing the array serialization description for the 'array of string' type object. 

However, I see there is a remark describe it is an array in the pas generated by WSDL, but this description does not exist in the XML generated by SOAP client finally.

//WSDL
ArrayOfstring = array of string;              { "http://schemas.microsoft.com/2003/10/Serialization/Arrays"[GblCplx] }


How to pass an array to SOAP API? It seems Delphi do not know the variable is an array, it just take the first row. How to add back the description "xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays" to header node? Do I miss something in the client side? Thanks for your help.
 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×