使用SoapUI测试WCF服务时SOAP Action不匹配错误

时间:2014-08-26 13:09:23

标签: wcf soapui

使用SOAPUI中的示例输入测试WCF服务。当我点击运行时,我得到如下的SOAP异常:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
   <s:Header>
     <a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/fault</a:Action>
   </s:Header>
<s:Body>
 <s:Fault>
     <s:Code>
        <s:Value>s:Sender</s:Value>
        <s:Subcode>
           <s:Value>a:ActionMismatch</s:Value>
        </s:Subcode>
     </s:Code>
     <s:Reason>
        <s:Text xml:lang="en-US">The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://XXX.XX.XXXX/IXXXXXX/AddOrderInfromation'.</s:Text>
     </s:Reason>
     <s:Detail>
        <a:ProblemHeaderQName>a:Action</a:ProblemHeaderQName>
     </s:Detail>
  </s:Fault>
 </s:Body>
</s:Envelope>

在博客中,他们要求添加Soap Action。如何在我的请求中添加肥皂动作:

 <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wkus="http://XXX.XX.XXXX/IXXXXXX">
  <soap:Header />
  <soap:Body>
  <ns1:AddOrderInfromation>
     <!--Optional:-->
     <ns1:inputsting>
<ns1:AddOrderInfromation>
  <ns1:OrderNo>4500146</ns1:OrderNo>
  <ns1:OrderDate>08/22/2014</ns1:OrderDate>
  <ns1:TotalItems>1</ns1:TotalItems>         
</ns1:AddOrderInfromation>
 </ns1:inputsting>
 </ns1:AddOrderInfromation>

请建议。在此先感谢

5 个答案:

答案 0 :(得分:21)

这可能是WS-A寻址问题。

在Request的WS-A选项卡中,选中“Enable WS-A addressing”。 您可能还需要选中“添加默认值为:到”。

答案 1 :(得分:6)

您的Web服务正在返回一个SOAPFault,它表示Web服务需要SOAP Action http标头。为了在SOAPUI的SOAP请求中添加SOAP操作,您必须添加一个名为SOAPAction的http头,以便执行下一步:

  • 在SOAP测试请求的底部有一些标签(Header(0)Attachments(0) ...),打开Header(0)标签。然后使用+添加按钮,添加一个包含SOAPAction名称和您的值的标题:

enter image description here

希望这有帮助,

答案 2 :(得分:2)

由于xml请求中的语法不正确,也会发生此错误

对于Eg:如果是,它将抛出相同的错误 关闭标签缺失

    </soap:Body>
</soap:Envelope>

以下代码

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wkus="http://XXX.XX.XXXX/IXXXXXX">
    <soap:Header />
    <soap:Body>
        <ns1:AddOrderInfromation>
            <ns1:inputsting>
                <ns1:AddOrderInfromation>
                    <ns1:OrderNo>4500146</ns1:OrderNo>
                    <ns1:OrderDate>08/22/2014</ns1:OrderDate>
                    <ns1:TotalItems>1</ns1:TotalItems>         
                </ns1:AddOrderInfromation>
            </ns1:inputsting>
        </ns1:AddOrderInfromation>

或者如果有这样的意外语法

    <ns1:OrderNo>4500146**<ns1:OrderNo>**

而不是

    <ns1:OrderNo>4500146**</ns1:OrderNo>**

或者

    <ns1:**OrderNo**4500146</ns1:OrderNo>

而不是

    <ns1:**OrderNo>**4500146</ns1:OrderNo>

答案 3 :(得分:2)

我也有这个问题,并通过在SopaUI中启用WS-A寻址解决了这个问题。 screenshot from SoapUI

答案 4 :(得分:0)

我刚刚遇到了类似的问题。我解决了如下问题;

https://blabla.com/xyz.svc?wsdl --> 到浏览器的 wsdl url,你会看到一些方法里面的动作;

enter image description here

我使用python进行开发,并添加了如下所示的soapAction;

headers = {'Content-type': 'text/xml;charset=UTF-8',
           'SOAPAction': 'http://tempuri.org/IArasCargoIntegrationService/GetQueryXML'
           }

它奏效了。

相关问题