title: SOAP returns data, but C# says null response
body: <p>My C# app won't give me anything but null results from SOAP calls.</p>
  
  <p>We have exposed some PeopleSoft ERP data with a SOAP web service.</p>
  
  <p>I am accessing this SOAP service from a Visual Studio 2012 ASP.NET C# app. I have a Service Reference named <strong>CampusDirectoryService</strong> built using the WSDL generated by the ERP.</p>
  
  <p>Here's the C# code:</p>
  
  <pre><code>var service = new CampusDirectoryService.TEST_PortTypeClient();
  var input = new CampusDirectoryService.InputParameters();
  input.First_Name = FirstNameBox.Text;
  input.Last_Name = LastNameBox.Text;
  var returnData = service.TEST_OP(input);
  </code></pre>
  
  <p>The problem is <code>returnData</code> is always null. Through Wireshark, I confirmed that I am in fact getting a valid SOAP response with data. <code>returnData</code> should not be null.</p>
  
  <p>I have confirmed correct valid results from the SOAP service through <a href="http://www.soapui.org/" rel="noreferrer">soapUI</a>, too. Submitting the exact same SOAP request that .NET sends (I copied it out of Wireshark), I get expected results.</p>
  
  <p>Here's the SOAP 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;InputParameters xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas"&gt;
        &lt;Last_Name xmlns=""&gt;cambre&lt;/Last_Name&gt;
        &lt;First_Name xmlns=""&gt;aren&lt;/First_Name&gt;
      &lt;/InputParameters&gt;
    &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>Here's the SOAP response, with some internal data inside the <code>ReturnID</code> element obfuscated or removed:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
     &lt;soapenv:Body&gt;
        &lt;root xmlns="http://peoplesoft.com/rootResponse"&gt;
           &lt;ReturnID&gt;
              &lt;PRF_Name&gt;Cambre,Aren&lt;/PRF_Name&gt;
              &lt;Camp_Email&gt;valid@email.com&lt;/Camp_Email&gt;
           &lt;/ReturnID&gt;
        &lt;/root&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>The return type of the <code>TEST_OP</code> method is <code>CampusDirectoryService.rootReturnID[]</code>.</p>
  
  <p>Why is <code>returnData</code> always null?</p>
  
  <p><strong>UPDATE</strong>
  Per a comment, I validated the messages with soapUI. It's squawking on the response with this message:</p>
  
  <p><strong>line -1: Missing message part with name [{<a href="http://xmlns.oracle.com/Enterprise/Tools/schemas" rel="noreferrer">http://xmlns.oracle.com/Enterprise/Tools/schemas</a>}root]</strong></p>
  
  <p>Here's the XSD for the response:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema targetNamespace="http://xmlns.oracle.com/Enterprise/Tools/schemas" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;xs:element name="root"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element maxOccurs="unbounded" name="ReturnID"&gt;
            &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                &lt;xs:element name="PRF_Name" type="xs:string" /&gt;
                &lt;xs:element name="Camp_Email" type="xs:string" /&gt;
              &lt;/xs:sequence&gt;
            &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
        &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>Is the XSD supposed to validate what's inside <code>soapenv:Body</code>, or is it supposed to validate the entire response, including the <code>soapenv:Envelope</code> and <code>soapenv:Body</code> elements? Looks like soapUI expects the XSD to validate the entire response, not just what's inside <code>soapenv:Body</code>.</p>
  
  <p>Here's the WSDL:</p>
  
  <pre><code>&lt;wsdl:definitions name="TEST.1" targetNamespace="http://xmlns.oracle.com/Enterprise/HCM/schemas/TEST.1" xmlns:U_IT_CAMDIR_REQUEST_MSG.VERSION_1="http://xmlns.oracle.com/Enterprise/Tools/schemas" xmlns:U_IT_CAMDIR_RESPONSE_MSG.VERSION_1="http://xmlns.oracle.com/Enterprise/Tools/schemas" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://xmlns.oracle.com/Enterprise/HCM/schemas/TEST.1" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"&gt;
     &lt;wsp:UsagePolicy wsdl:Required="true"/&gt;
     &lt;plnk:partnerLinkType name="TEST_PartnerLinkType"&gt;
        &lt;plnk:role name="TEST_Provider"&gt;
           &lt;plnk:portType name="tns:TEST_PortType"/&gt;
        &lt;/plnk:role&gt;
     &lt;/plnk:partnerLinkType&gt;
     &lt;wsdl:types&gt;
        &lt;xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
           &lt;xsd:import namespace="http://xmlns.oracle.com/Enterprise/Tools/schemas" schemaLocation="U_IT_CAMDIR_REQUEST_MSG.VERSION_1.xsd"/&gt;
           &lt;xsd:import namespace="http://xmlns.oracle.com/Enterprise/Tools/schemas" schemaLocation="U_IT_CAMDIR_RESPONSE_MSG.VERSION_1.xsd"/&gt;
        &lt;/xsd:schema&gt;
     &lt;/wsdl:types&gt;
     &lt;wsdl:message name="U_IT_CAMDIR_REQUEST_MSG.VERSION_1"&gt;
        &lt;wsdl:documentation&gt;People Directory&lt;/wsdl:documentation&gt;
        &lt;wsdl:part element="U_IT_CAMDIR_REQUEST_MSG.VERSION_1:InputParameters" name="parameter"/&gt;
     &lt;/wsdl:message&gt;
     &lt;wsdl:message name="U_IT_CAMDIR_RESPONSE_MSG.VERSION_1"&gt;
        &lt;wsdl:documentation&gt;People Directory&lt;/wsdl:documentation&gt;
        &lt;wsdl:part element="U_IT_CAMDIR_RESPONSE_MSG.VERSION_1:root" name="parameter"/&gt;
     &lt;/wsdl:message&gt;
     &lt;wsdl:portType name="TEST_PortType"&gt;
        &lt;wsdl:operation name="TEST_OP"&gt;
           &lt;wsdl:documentation&gt;TEST&lt;/wsdl:documentation&gt;
           &lt;wsdl:input message="tns:U_IT_CAMDIR_REQUEST_MSG.VERSION_1" name="U_IT_CAMDIR_REQUEST_MSG.VERSION_1"/&gt;
           &lt;wsdl:output message="tns:U_IT_CAMDIR_RESPONSE_MSG.VERSION_1" name="U_IT_CAMDIR_RESPONSE_MSG.VERSION_1"/&gt;
        &lt;/wsdl:operation&gt;
     &lt;/wsdl:portType&gt;
     &lt;wsdl:binding name="TEST_Binding" type="tns:TEST_PortType"&gt;
        &lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
        &lt;wsdl:operation name="TEST_OP"&gt;
           &lt;soap:operation soapAction="TEST_OP.v1" style="document"/&gt;
           &lt;wsp:Policy wsu:Id="UsernameTokenSecurityPolicyPasswordOptional" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
              &lt;wsp:ExactlyOne&gt;
                 &lt;wsp:All&gt;
                    &lt;wsse:SecurityToken wsp:Usage="wsp:Required" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
                       &lt;wsse:TokenType&gt;wsse:UserNameToken&lt;/wsse:TokenType&gt;
                       &lt;Claims&gt;
                          &lt;SubjectName MatchType="wsse:Exact"/&gt;
                          &lt;UsePassword wsp:Usage="wsp:Optional"/&gt;
                       &lt;/Claims&gt;
                    &lt;/wsse:SecurityToken&gt;
                 &lt;/wsp:All&gt;
              &lt;/wsp:ExactlyOne&gt;
           &lt;/wsp:Policy&gt;
           &lt;wsdl:input name="U_IT_CAMDIR_REQUEST_MSG.VERSION_1"&gt;
              &lt;soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/&gt;
           &lt;/wsdl:input&gt;
           &lt;wsdl:output name="U_IT_CAMDIR_RESPONSE_MSG.VERSION_1"&gt;
              &lt;soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/&gt;
           &lt;/wsdl:output&gt;
        &lt;/wsdl:operation&gt;
     &lt;/wsdl:binding&gt;
     &lt;wsdl:service name="TEST"&gt;
        &lt;wsdl:documentation&gt;TEST&lt;/wsdl:documentation&gt;
        &lt;wsdl:port binding="tns:TEST_Binding" name="TEST_Port"&gt;
           &lt;soap:address location="http://domainname.com/longurltoSOAPservicehere"/&gt;
        &lt;/wsdl:port&gt;
     &lt;/wsdl:service&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>