title: gSoap: HTTP Header, Content-Length: 0
body: <p>I am attempting to use gSoap in a c++ client to access the salesforce.com API using the below code:</p>
  
  <pre><code>struct soap soap;
  
  soap_init(&amp;soap);
  
  _ns1__login loginReq;
  _ns1__loginResponse loginRes;
  
  loginReq.username = "XXXX";
  loginReq.password = "XXXX";
  
  if(soap_call___ns1__login(&amp;soap,NULL,NULL,&amp;loginReq,&amp;loginRes) == 0){
      qDebug() &lt;&lt; loginRes.result-&gt;sessionId;
  } else {
      soap_print_fault(&amp;soap, stderr);
      soap_print_fault_location(&amp;soap, stderr);
  }
  </code></pre>
  
  <p>This complies without a problem but when run produces the following error:</p>
  
  <pre><code>SOAP 1.1 fault: SOAP-ENV:Client [no subcode]
  "Validation constraint violation: tag name or namespace mismatch in element &lt;soapenv:Envelope&gt;"
  Detail: [no detail]
  HTTP/1.1 500 Internal Server Error
  Server: 
  Content-Type: text/xml; charset=UTF-8
  Content-Length: 625
  Date: Fri, 29 Apr 2011 00:56:17 GMT
  Connection: close
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;&lt;soapenv:Body&gt;&lt;soapenv:Fault&gt;&lt;faultcode&gt;UNKNOWN_EXCEPTION&lt;/faultcode&gt;&lt;faultstring&gt;UNKNOWN_EXCEPTION: Premature end of file.&lt;/faultstring&gt;&lt;detail&gt;&lt;sf:UnexpectedErrorFault xsi:type="sf:UnexpectedErrorFault"&gt;&lt;sf:exceptionCode&gt;UNKNOWN_EXCEPTION&lt;/sf:exceptionCode&gt;&lt;sf:exceptionMessage&gt;Premature end of file.&lt;/sf:exceptionMessage&gt;&lt;/sf:UnexpectedErrorFault&gt;&lt;/detail&gt;&lt;/soapenv:Fault&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;
  &lt;!-- ** HERE ** --&gt;
  </code></pre>
  
  <p>I have run a packet capture and everything looks correct except for the 'Content-Length' in the HTTP header shows 0:</p>
  
  <pre><code>POST /services/Soap/c/21.0 HTTP/1.1
  Host: login.salesforce.com
  User-Agent: gSOAP/2.7
  Content-Type: text/xml; charset=utf-8
  Content-Length: 0
  Connection: close
  SOAPAction: ""
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="urn:sobject.enterprise.soap.sforce.com" xmlns:ns3="urn:fault.enterprise.soap.sforce.com" xmlns:ns1="urn:enterprise.soap.sforce.com"&gt;&lt;SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;&lt;ns1:login&gt;&lt;ns1:username&gt;XXXX&lt;/ns1:username&gt;&lt;ns1:password&gt;XXXX&lt;/ns1:password&gt;&lt;/ns1:login&gt;&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>If anyone has any insights into where I am going wrong it would be greatly appreciated.</p>
  
  <p>I am using gSoap 2.7 on Debian 6.0 using g++ 4.4.5 to compile if that is any help.</p>