2014-04-03 165 views
-1

我想通過C調用webservice。我不能使用任何現有的庫。所以我打開Tomcat端口8080上的套接字(某些應用程序在Tomcat上運行)。通過HTTP在C套接字中發送的SOAP消息

我發送HTTP POST請求來經由插座,其包括SOAP消息的Tomcat。我能夠調用webservice,但無法接收以SOAP形式發送的數據。這裏是一個HTTP請求與SOAP,我通過套接字發送給Tomcat

POST http://hostip.com:8080/APP/WebServiceName HTTP/1.1 
Accept-Encoding: gzip,deflate 
Content-Type: text/xml;charset=UTF-8 
SOAPAction: "http://www.companyname.com/webservices" 
User-Agent: Jakarta Commons-HttpClient/3.1 
Host: 192.168.50.151 
Content-Length: length 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.company.com/webservices"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <web:DataRequest> 
     <web:Scope>iOWNjuYroYC6HB</web:Scope> 
     <web:Source> 

      <web:ChildLine> 
       <web:ID>RnUNjuYroYC6HB</web:ID> 
       <web:Matrix>15</web:Matrix> 
      </web:ChildLine> 
     </web:Source> 
     <web:UserVariables>   
      <web:Variable> 
       <web:Key>Rule</web:Key> 
       <web:Value>Working</web:Value> 
      </web:Variable> 
      <web:Variable> 
       <web:Key>543</web:Key> 
       <web:Value>96</web:Value> 
      </web:Variable> 
     </web:UserVariables> 
     </web:DataRequest> 
    </soapenv:Body> 
</soapenv:Envelope> 
+2

歡迎來到stackoverflow.com。請花些時間閱讀[幫助頁面](http://stackoverflow.com/help),尤其是名爲[「我可以問些什麼話題?」]的章節(http://stackoverflow.com/help/)討論話題)和[「我應該避免問什麼類型的問題?」](http://stackoverflow.com/help/dont-ask)。更重要的是,請閱讀[Stack Overflow問題清單](http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist)。您可能還想了解如何創建[最小化,完整和可驗證的示例](http://stackoverflow.com/help/mcve)。 –

回答

0

我不確定我是否完全理解你。 但是...如果您發送此示例消息一對一,這將是不正確的。 您需要在「Content-Length:length」部分使用數字將「length」文本更改爲實際長度。我認爲你改變了真正的長度(以字節爲單位,沒有標題長度),那麼結果可能會更好。

+0

嗨,其實我正在把適當的長度在那裏......我計數我的消息的長度,然後使用snprintf我插入長度... – user3467731