手卷SOAP请求 [英] Hand rolled SOAP request

查看:109
本文介绍了手卷SOAP请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个手动滚动的HTTP请求,以便从我认为相当简单的SOAP Web服务调用返回响应。但是,我无法正确构建请求,并且没有得到我期望的响应。

I am trying to construct a hand rolled HTTP request in order to return a response from what I thought was a fairly simple SOAP web service call. However, I am having trouble constructing the request properly, and am not getting the response I expect.

wsdl目标命名空间:

targetNamespace="http://tempuri.org/"

wsdl服务

<wsdl:service name="TrackerService">
  <wsdl:port name="BasicHttpBinding_ITrackerService" binding="tns:BasicHttpBinding_ITrackerService">
    <soap:address location="http://mydomain.com/TrackerServiceSite/wctest2.TrackerService.svc"/>
  </wsdl:port>
</wsdl:service>

wsdl消息

<wsdl:message name="ITrackerService_GetStub_InputMessage">
  <wsdl:part name="parameters" element="tns:GetStub" /> 
</wsdl:message>
<wsdl:message name="ITrackerService_GetStub_OutputMessage">
  <wsdl:part name="parameters" element="tns:GetStubResponse" /> 
</wsdl:message>

wsdl绑定和SOAP操作

<wsdl:binding name="BasicHttpBinding_ITrackerService" type="tns:ITrackerService">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
        .
        . <!—- Omitted for brevity --> 
        .
  <wsdl:operation name="GetStub">
    <soap:operation soapAction="http://tempuri.org/ITrackerService/GetStub" style="document"/>
    <wsdl:input>
        <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
        <soap:body use="literal"/>
    </wsdl:output>
  </wsdl:operation>
</wsdl:binding>






预期退货回复




EXPECTED Return Response

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header />
  <s:Body>
      <GetStubResponse xmlns="http://tempuri.org/">
        <GetStubResult xmlns:a=http://schemas.datacontract.org/2004/07/wctest2 xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
          <a:Password>SOMEPASS</a:Password>
          <a:Username>SOMEUSER</a:Username>
        </GetStubResult>
      </GetStubResponse>
  </s:Body>
</s:Envelope>






到目前为止的HTTP请求:




HTTP request thus far:

POST http://mydomain.com/TrackerServiceSite/wctest2.TrackerService.svc HTTP/1.1
Content-Type: text/xml; charset="utf-8"
Content-Length: 297
Host: mydomain.com

<soap:Envelope
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
       <GetStub xmlns="http://tempuri.org/"/>
   </soap:Body>
</soap:Envelope>



HTTP响应



HTTP Response

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <s:Fault>
      <faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode>
      <faultstring xml:lang="en-US">
          The message with Action '' cannot be processed at the receiver, due to a 
          ContractFilter mismatch at the EndpointDispatcher. This may be because of 
          either a contract mismatch (mismatched Actions between sender and receiver) 
          or a binding/security mismatch between the sender and the receiver.  Check 
          that sender and receiver have the same contract and the same binding 
          (including security requirements, e.g. Message, Transport, None).
      </faultstring>
    </s:Fault>
  </s:Body>
</s:Envelope>






我很确定我需要包含一个来自我请求中某处的wsdl文件的 soapAction ,但我不知道在哪里包含它。我还缺少什么?任何帮助将不胜感激。


I am pretty sure that I need to include a soapAction from the wsdl file somewhere in my request, but I'm not sure where to include it. What else am I missing? Any help would be greatly appreciated.

推荐答案

将你的肥皂行动放在 SOAPAction HTTP标头

Place your soap action in the SOAPAction HTTP header

这篇关于手卷SOAP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆