Note that there are some explanatory texts on larger screens.

plurals
  1. PONot showing data from SOAP service
    text
    copied!<p>I have an interesting problem involving a C# console client and a web service. My suspicion is that there is a name space error somewhere or something simple, but eight hours of staring blankly into the screen has yet to reveal them so I thought I'd try a few more eyes.</p> <p>WSDL</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;wsdl:definitions xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http:// schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:schema="http://xxx.com/BillOfMaterials/schemas" xmlns:tns="http:// xxx.com/BillOfMaterials/definitions" targetNamespace="http://xxx.com/BillOfMaterials/definitions"&gt; &lt;wsdl:types&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:import namespace="http://xxx.com/BillOfMaterials/ schemas" schemaLocation="BOMRequest.xsd" id="input"/&gt; &lt;xs:import namespace="http://xxx.com/BillOfMaterials/schemas" schemaLocation="BOMResponse.xsd" id="output"/&gt; &lt;/xs:schema&gt; &lt;/wsdl:types&gt; &lt;wsdl:message name="BomRequest"&gt; &lt;wsdl:part name="input" element="schema:BOMin"/&gt; &lt;/wsdl:message&gt; &lt;wsdl:message name="BomResponse"&gt; &lt;wsdl:part name="output" element="schema:BOMResponse"/&gt; &lt;/wsdl:message&gt; &lt;wsdl:portType name="BOMPortType"&gt; &lt;wsdl:operation name="BOM"&gt; &lt;wsdl:input message="tns:BomRequest"/&gt; &lt;wsdl:output message="tns:BomResponse"/&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:portType&gt; &lt;wsdl:binding name="BOMBinding" type="tns:BOMPortType"&gt; &lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/ http"/&gt; &lt;wsdl:operation name="BOM"&gt; &lt;soap:operation soapAction="urn:#BOMOperation"/&gt; &lt;wsdl:input&gt; &lt;soap:body use="literal"/&gt; &lt;/wsdl:input&gt; &lt;wsdl:output&gt; &lt;soap:body use="literal"/&gt; &lt;/wsdl:output&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:binding&gt; &lt;wsdl:service name="BOMService"&gt; &lt;wsdl:port name="BOMPort" binding="tns:BOMBinding"&gt; &lt;soap:address location="http://xxx/BOM"/&gt; &lt;/wsdl:port&gt; &lt;/wsdl:service&gt; &lt;/wsdl:definitions&gt; </code></pre> <p>Request XSD</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/ XMLSchema" xmlns:in="http://secotools.com/BillOfMaterials/schemas" targetNamespace="http://xxx.com/BillOfMaterials/schemas" elementFormDefault="qualified"&gt; &lt;xs:element name="BOMin" type="in:BOMRequestItem"/&gt; &lt;xs:complexType name="BOMRequestItem"&gt; &lt;xs:sequence&gt; &lt;xs:element name="ProductNumber" type="xs:string"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:schema&gt; </code></pre> <p>Response XSD (shortened as it's well large)</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/ XMLSchema" xmlns:in="http://xxx.com/BillOfMaterials/schemas" targetNamespace="http://xxx.com/BillOfMaterials/schemas" elementFormDefault="qualified"&gt; &lt;xs:element name="BOMResponse"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="BOMResponses" type="in:BOMResponseItem" minOccurs="0" maxOccurs="unbounded"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:complexType name="BOMResponseItem"&gt; &lt;xs:sequence&gt; &lt;xs:element name="Company" type="xs:string"/&gt; &lt;xs:element name="Facility" type="xs:string"/&gt; &lt;xs:element name="ProductNumber" type="xs:string"/&gt; &lt;xs:element name="ProductStructureType" type="xs:string"/&gt; &lt;xs:element name="Name" type="xs:string"/&gt; </code></pre> <p>Using this WSDL I get the following request and response in soapUI: SoapUI request:</p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://xxx.com/BillOfMaterials/schemas"&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;sch:BOMin&gt; &lt;ProductNumber&gt;12345&lt;/ProductNumber&gt; &lt;/sch:BOMin&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p>SoapUI response (shortened for readability):</p> <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:out="http://xxx.com/BillOfMaterials/schemas"&gt; &lt;SOAP-ENV:Header/&gt; &lt;SOAP-ENV:Body&gt; &lt;out:BOMResponse&gt; &lt;Company&gt;1&lt;/Company&gt; &lt;Facility&gt;1&lt;/Facility&gt; &lt;ProductNumber&gt;12345&lt;/ProductNumber&gt; &lt;ProductStructureType&gt;PLU&lt;/ProductStructureType&gt; &lt;Name&gt;My dummy product&lt;/Name&gt; </code></pre> <p>I've tried both generating a proxy with svcutil and used a service reference in C# to no avail. SoapUI works as expected and returns data while C# get an empty list.</p> <p>C# test code</p> <pre><code>class Program { static void Main(string[] args) { BOMPortTypeClient _client = new BOMPortTypeClient(); var state = _client.State; BOMRequestItem _reqItem = new BOMRequestItem { ProductNumber = "12345" }; IList&lt;BOMResponseItem&gt; _list = _client.BOM(_reqItem); } } </code></pre> <p>Edit: Added Fiddler logs with request/response from .Net</p> <p>.Net request</p> <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;BOMin xmlns="http://xxx.com/BillOfMaterials/schemas"&gt; &lt;ProductNumber&gt;12345&lt;/ProductNumber&gt; &lt;/BOMin&gt; &lt;/s:Body&gt; &lt;/s:Envelope&gt; </code></pre> <p>.Net response</p> <pre><code>&lt;?xml version="1.0" ?&gt; &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://xxx.com/BillOfMaterials/schemas" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;s:Header/&gt; &lt;s:Body&gt; &lt;BOMResponse&gt; &lt;Company&gt;1&lt;/Company&gt; &lt;Facility&gt;1&lt;/Facility&gt; &lt;ProductNumber&gt;12345&lt;/ProductNumber&gt; &lt;ProductStructureType&gt;PLU&lt;/ProductStructureType&gt; &lt;Name&gt;My dummy product&lt;/Name&gt; </code></pre> <p>Since I do get data back I know the service understands the request from .Net, problem is .Net seems unable to understand the response. This is why I thought at first it was a namespace issue. Now I'm not so sure anymore. I get no errors in .Net, just an empty array.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload