I need to pass array list to SOAP service:
var arrayList = new ArrayList
{
"simple",
"4",
"two",
new StringKeyValuePair {Key = "name", Value = "product name"}
};
[Serializable]
public struct StringKeyValuePair
{
public string Key { get; set; }
public string Value { get; set; }
}
Call looks like:
client.call(sessionId, "product.create", arrayList);
And WSDL looks like:
<message name="call">
<part name="sessionId" type="xsd:string"/>
<part name="resourcePath" type="xsd:string"/>
<part name="args" type="xsd:anyType"/>
</message>
Problem is, that soap client can’t serialize it, as StringKeyValuePair is not expected type. I can not wrap it into class as a property, as that would result in additional xml, that soap service will not understand (can not change soap service).
I’ve found a problem and a solution. Thing is, that client was unaware what types to expect, as long as args parameter type was any.
So solution was to add KnowType to operation (in sample below it is added to all operations):
Then it works as supposed to work.