Hi there,
I have a webservice programmed in coldfusion which I'm attempting to consume using c#.net.
The particular webservices returns a coldfusion structure (a collection of items with a key and a value) which is exposed by the webservice as a complex object of type apachesoap:Map
<wsdl:message name="getDetailResponse">
<wsdl:part name="getDetailReturn" type="apachesoap:Map"/>
</wsdl:message>
The complex type is correctly declared in the WSDL file automatically generated by coldfusion
<schema targetNamespace="http://xml.apache.org/xml-soap">
<import namespace="http://webservice.templates"/>
<import namespace="http://rpc.xml.coldfusion"/>
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="mapItem">
<sequence>
<element name="key" nillable="true" type="xsd:anyType"/>
<element name="value" nillable="true" type="xsd:anyType"/>
</sequence>
</complexType>
<complexType name="Map">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item" type="apachesoap:mapItem"/>
</sequence>
</complexType>
</schema>
When attempting to consume this using the following c# code:
theWebservice.theWebservice myWS = new theWebservice.theWebservice();
theWebservice.Map myMap = myWS.searchForRecord("some record data");
if (myMap.item == null) {
Response.Write("myMap.item is null");
}
The code compiles fine but displays the "myMap.item is null" rather than being an object with a key and value pair.
Inspection with the debugger shows myMap has two children item and itemField both of type theWebservice.mapItem[] and both of value null.
I've seen other forum posts with a similar issue but no replies, does anyone know how I can consume the service correctly without having to alter the webservice to use just simple types?
Edited to provide more information
As per John Saunders' questions, I'm using .NET Framework 3.5 in Visual Web Developer 2008. the webservice was included as a web reference and the response SOAP code is provided below (from soapUI):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:getDetailResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://DefaultNamespace">
<getDetailReturn xsi:type="ns2:Map" xmlns:ns2="http://xml.apache.org/xml-soap">
<item xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<key xsi:type="soapenc:string">a</key>
<value xsi:type="soapenc:string">1</value>
</item>
<item>
<key xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">b</key>
<value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">2</value>
</item>
</getDetailReturn>
</ns1:getDetailResponse>
</soapenv:Body>
</soapenv:Envelope>
Thanks,
Tom