【问题标题】:SOAP message through HTTP in C sockets通过 C 套接字中的 HTTP 的 SOAP 消息
【发布时间】:2014-04-03 14:09:50
【问题描述】:

我想通过 C 调用 webservice。我不能使用任何现有的库。所以我在 Tomcat 端口 8080 上打开套接字(某些应用程序正在 Tomcat 上运行)。

我正在通过包含 SOAP 消息的套接字向 tomcat 发送 HTTP POST 请求。我能够调用 web 服务,但我无法接收以 SOAP 形式发送的数据。这是一个带有 SOAP 的 HTTP 请求,我通过套接字发送到 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>

【问题讨论】:

标签: c sockets http soap httprequest


【解决方案1】:

我不确定我是否完全理解你。 但是...如果您一对一地发送此示例消息,那将是不正确的。 您需要在“Content-Length: length”部分使用 digits 将“length”文本更改为实际长度。我认为您更改为实际长度(以字节为单位,没有标头长度),那么结果可能会更好。

【讨论】:

  • 嗨,实际上我在那里放了适当的长度......我正在计算我的消息的长度,然后使用 snprintf 我正在插入长度......
最近更新 更多