简体   繁体   English

服务器无法识别 HTTP Header SOAPAction 的值

[英]Server did not recognize the value of HTTP Header SOAPAction

   [SoapRpcMethod(Action = "http://cyberindigo/TempWebService/InsertXML",
    RequestNamespace = "http://cyberindigo/TempWebService/Request",
    RequestElementName = "InsertXMLRequest",
    ResponseNamespace = "http://cyberindigo/TempWebService/Response",
    ResponseElementName = "InsertXMLResponse",
    Use = System.Web.Services.Description.SoapBindingUse.Literal)]

    [WebMethod]
    public string InsertXML(string Jobs)
    {
        return "Hi";
    }

The Problem when I am accessing it using XMLHttpRequest it gives following error Server did not recognize the value of HTTP Header SOAPAction: http://Cyberindigo/TempWebService/InsertXML当我使用 XMLHttpRequest 访问它时出现以下错误服务器无法识别 HTTP 标头 SOAPAction 的值: http://Cyber​​indigo/TempWebService/InsertXML

The source of the next part of this post is:这篇文章下一部分的来源是:

http://bluebones.net/2003/07/server-did-not-recognize-http-header-soapaction/ http://bluebones.net/2003/07/server-did-not-recognize-http-header-soapaction/

(since the OP didn't want to give attribution, and thanks to Peter) (因为 OP 不想给出归属,感谢彼得)

Please note that bakert is the original author of the text, not the OP.请注意,bakert 是文本的原作者,而不是 OP。


Seeing as nowhere on the internet can I find an explanation of this error I thought I'd share the fruits of my long search for this bug.在互联网上找不到任何地方可以找到此错误的解释,我想我会分享我长期搜索此错误的成果。

It means (at least in my case) that you are accessing a web service with SOAP and passing a SOAPAction parameter in the HTTP request that does not match what the service is expecting.这意味着(至少在我的情况下)您正在使用 SOAP 访问 Web 服务并在 HTTP 请求中传递与服务期望的不匹配的SOAPAction参数。

I got in a pickle because we moved a web service from one server to another and thus I changed the “namespace” (don't get confused between web service namespaces and .net namespaces) in the calling C# file to match the new server.我陷入了困境,因为我们将 Web 服务从一台服务器移动到另一台服务器,因此我更改了调用 C# 文件中的“命名空间”(不要混淆 Web 服务命名空间和 .net 命名空间)以匹配新服务器。 But the server doesn't care about the actual web reality of http://yournamespace.com/blah it only cares that you send it what you have said you are expecting on the server.但是服务器并不关心http://yournamespace.com/blah的实际网络现实,它只关心你发送它你所说的你期望在服务器上的内容。 It doesn't care if there's actually anything there or not.它不在乎那里是否真的有任何东西。

So basically the web service was moved from http://foo.com/servicename to http://bar.com/servicename but the “namespace” of the web service stayed as http://foo.com/servicename because no one changed it.所以基本上网络服务从http://foo.com/servicename移动到http://bar.com/servicename但网络服务的“命名空间”保持为http://foo.com/servicename因为没有人改变了它。

And that only took about 4 hours to work out!并且只用了大约 4 个小时就完成了!

If you're having a similar problem but can't work what I'm saying here, feel free to mail me on bakert+web@gmail.com – I wouldn't wish my four hours on anyone!如果您遇到了类似的问题,但无法解决我在这里所说的问题,请随时通过 bakert+web@gmail.com 给我发邮件——我不希望我的四个小时花在任何人身上!

While calling the .asmx / wcf web service please take care of below points:在调用 .asmx / wcf 网络服务时,请注意以下几点:

  1. The namespace is case sensitive,the SOAP request MUST be sent with the same namespace with which the WebService is declared.命名空间区分大小写,SOAP 请求必须使用与声明 WebService 相同的命名空间发送。

eg For the WebService declared as below例如对于声明如下的WebService

[WebService(Namespace = "http://MyDomain.com/TestService")] 
public class FooClass : System.Web.Services.WebService 
{
   [WebMethod]   
    public bool Foo( string name)    
     {

      ...... 
     }

 }

The SOAP request must maintain the same case for namespace while calling.Sometime we overlook the case sensitivity. SOAP 请求在调用时必须为命名空间保持相同的大小写。有时我们会忽略大小写敏感性。

<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>
     <Foo xmlns="http://MyDomain.com/TestService">
     <name>string</name>      
     </Foo>
  </soap:Body> 
</soap:Envelope>
  1. The namespace need not be same as hosted url of the service.The namespace can be any string.命名空间不必与服务的托管 url 相同。命名空间可以是任何字符串。

eg Above service may be hosted at http://84.23.9.65/MyTestService , but still while invoking the Web Service from client the namespace should be the same which the serice class is having ie http://MyDomain.com/TestService例如,上面的服务可能托管在http://84.23.9.65/MyTestService ,但仍然在从客户端调用 Web 服务时,命名空间应该与服务类具有的相同,即http://MyDomain.com/TestService

I agree with Sam in that the SOAP definition does not match what is expected.我同意 Sam 的观点,即 SOAP 定义与预期不符。 Here is just ONE solution it could be, I had to manually figure this error for myself:这只是一种解决方案,我必须自己手动计算这个错误:

My problem was that I changed the name of the web method but did not change the "MessageName" in the metadata tag.我的问题是我更改了 Web 方法的名称,但没有更改元数据标记中的“MessageName”。

[WebMethod(MessageName = "foo")]
public string bar()
{

}

It should be它应该是

[WebMethod(MessageName = "foo")]
public string foo()
{

}

hope that helps someone希望能帮助某人

I've decided to post my own answer here because I've lost a few hours on this and I think that, although the accepted answer is very good and pointed me in the right direction (yes, it got a voteup), it was not detailed enough to explain what was wrong with my application, at least in my case.我决定在这里发布我自己的答案,因为我在这个问题上浪费了几个小时,我认为,虽然接受的答案非常好并为我指明了正确的方向(是的,它得到了投票),但它是不够详细,无法解释我的应用程序出了什么问题,至少在我的情况下是这样。

I'm running a BPEL module in OpenESB 2.2 and the Test Case of my Composite Application was failing with the following error:我在 OpenESB 2.2 中运行 BPEL 模块,我的复合应用程序的测试用例失败并出现以下错误:

Caused by: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: .

After doing some research I've noticed that the external WSDL has all the clues we need to fix this problem, eg, I'm using the following web service to validate a credit card number through a orchestration of Web Services: http://www.webservicex.net/CreditCard.asmx?WSDL在做了一些研究之后,我注意到外部 WSDL 具有解决这个问题所需的所有线索,例如,我使用以下 Web 服务通过 Web 服务的编排来验证信用卡号: http:// www.webservicex.net/CreditCard.asmx?WSDL

If you check the <wsdl:operation elements you will see that it clearly states the soapAction for that operation:如果您检查<wsdl:operation元素,您将看到它清楚地说明了该操作的soapAction

<wsdl:binding name="CCCheckerSoap" type="tns:CCCheckerSoap">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
  <wsdl:operation name="ValidateCardNumber">
    <soap:operation soapAction="http://www.webservicex.net/ValidateCardNumber" style="document"/>
    <wsdl:input>
  <soap:body use="literal"/>
</wsdl:input>
...

But, once you create the Composite Application and build the project with the BPEL that invokes this external WSDL service, for some reason (bug?), the XML of the Composite Application Service Assembly (CASA) binding is generated with an empty soapAction parameter:但是,一旦您创建了复合应用程序并使用调用此外部 WSDL 服务的 BPEL 构建项目,出于某种原因(错误?),复合应用程序服务程序集 (CASA) 绑定的 XML 将使用空的soapAction参数生成:

<binding name="casaBinding1" type="ns:CCCheckerSoap">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="ValidateCardNumber">
            <soap:operation soapAction="" style="document"/>
            <input>
                <soap:body use="literal"/>
            </input>

Once you copy the proper soapAction (http://www.webservicex.net/ValidateCardNumber) into this parameter, the application's Test Case will correctly and return the expected Soap response.一旦您将正确的soapAction (http://www.webservicex.net/ValidateCardNumber) 复制到此参数中,应用程序的测试用例将正确并返回预期的Soap 响应。

<soap:operation soapAction="http://www.webservicex.net/ValidateCardNumber" style="document"/>

So, it's a more specific solution that I decided to document based on the information found in this blog post: http://bluebones.net/2003/07/server-did-not-recognize-http-header-soapaction/ .所以,这是一个更具体的解决方案,我决定根据这篇博文中的信息记录下来: http : //bluebones.net/2003/07/server-did-not-recognize-http-header-soapaction/

It means (at least in my case) that you are accessing a web service with SOAP and passing a SOAPAction parameter in the HTTP request that does not match what the service is expecting .这意味着(至少在我的情况下)您正在使用 SOAP 访问 Web 服务并在 HTTP 请求中传递与服务期望的不匹配的 SOAPAction 参数

I had same problem, it fixed after some checking:我有同样的问题,经过一些检查后解决了:

<< Target WebService Exists but called method's not eXXXists. << 目标 WebService 存在但被调用的方法不是 eXXXists。 >> >>

my local service contain methods but target server(connecting server) does not contain specified called method.我的本地服务包含方法,但目标服务器(连接服务器)不包含指定的调用方法。

Check your program scenario again...再次检查您的程序场景...

只是为了帮助某人解决这个问题,经过一个下午的调试,问题是 Web 服务是用框架 4.5 开发的,来自 android 的调用必须用 SoapEnvelope.VER12 完成,而不是用 SoapEnvelope.VER11

I had similar issue.我有类似的问题。 To debug the problem, I've run Wireshark and capture request generated by my code.为了调试问题,我运行了Wireshark并捕获了我的代码生成的请求。 Then I used XML Spy trial to create a SOAP request (assuming you have WSDL) and compared those two.然后我使用XML Spy 试验来创建一个 SOAP 请求(假设您有 WSDL)并比较这两个请求。

This should give you a hint what goes wrong.这应该会给你一个提示是什么地方出了问题。

I had this same problem, but the solution for me was that I was pointing to the wrong web service.我遇到了同样的问题,但对我来说,解决方案是我指向了错误的 Web 服务。 I had updated the web reference correctly.我已经正确更新了网络参考。 But we store the URl for the service in an encrypted file, and I didn't update the file with the correct service encrypted.但是我们将服务的 URl 存储在加密文件中,并且我没有使用加密的正确服务更新文件。

But all these suggestions really helped me to realize where to go for debugging.但所有这些建议确实帮助我意识到去哪里调试。

Thanks!谢谢!

I had the same problem after changing the namespace from "tempuri" in my Web Service.在我的 Web 服务中从“tempuri”更改命名空间后,我遇到了同样的问题。

You have to update your Service Reference in the project that is consuming the above service, so it can get the latest SOAP definitions.您必须在使用上述服务的项目中更新您的服务引用,以便它可以获得最新的 SOAP 定义。

Or at least that worked for me.或者至少这对我有用。 :) :)

我们重命名了一些 webservice 项目命名空间,但忘记使用重命名项目的命名空间更新网站 httphandlers 配置部分。

My error fixed by answer Mr. John Saunders : http://forums.asp.net/post/2906487.aspx我的错误由 John Saunders 先生的回答修复: http : //forums.asp.net/post/2906487.aspx

in short: difference between Namespace of ws .asmx.cs with ws .wsdl files.简而言之:ws .asmx.cs 的命名空间与 ws .wsdl文件之间的区别。

1) [WebService(Namespace = "http://tempuri.org/")]

later web service namespace changed to :后来 Web 服务命名空间更改为:

2) [WebService(Namespace = "http://newvalue.com/")]

so we referenced (1) in application and web service is (2) now.所以我们在 application 和 web service 中引用了 (1) 现在是 (2)。

make them equal to fix your problem.让他们等于解决你的问题。

我遇到了同样的错误,我能够通过删除“Web 引用”并添加“服务引用”来解决它

I got this error when I tried to call a method which did not exist.当我尝试调用不存在的方法时出现此错误。 It only existed in a newer version of our webservice.它只存在于我们的网络服务的较新版本中。

I had a similar problem with the same error message:我有同样的错误消息的类似问题:

System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction : System.Web.Services.Protocols.SoapException:服务器无法识别 HTTP Header SOAPAction的值:

We utilize dynamic URL's in our web service calls.我们在 Web 服务调用中使用动态 URL。 We have a central configuration server that manages the location of all web service calls so that our code can run in DEV, test or live without recompiling.我们有一个中央配置服务器来管理所有 Web 服务调用的位置,以便我们的代码可以在 DEV 中运行、测试或实时运行而无需重新编译。 The URL for a specific web service call for the test environment was incorrect in our configuration server.在我们的配置服务器中,用于测试环境的特定 Web 服务调用的 URL 不正确。 The web service call was being sent to the wrong server and the wrong web service. Web 服务调用被发送到错误的服务器和错误的 Web 服务。

So this error can simply be the result of the web service request not matching the web service being called.因此,此错误可能只是 Web 服务请求与被调用的 Web 服务不匹配的结果。

It took running fiddler on the Web App server to see that the actual call was to the incorrect web service.在 Web App 服务器上运行 fiddler 才发现实际调用的是不正确的 Web 服务。

the problem is in the System.Web.Services.Protocols.SoapDocumentMethodAttribute in the service.问题出在服务中的 System.Web.Services.Protocols.SoapDocumentMethodAttribute 中。 Please check it.请检查一下。 it may changed.它可能会改变。

我发现我的 Web 引用已过期,并且代码正在调用已删除的 Web 服务。

I had to sort out capitalisation of my service reference, delete the references and re add them to fix this.我不得不整理我的服务引用的大小写,删除引用并重新添加它们来解决这个问题。 I am not sure if any of these steps are superstitious, but the problem went away.我不确定这些步骤中是否有任何一个是迷信的,但问题就解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM