如何使用 AXis 1.4 创建 java 客户端以使用 wsHttpBinding 消费 WCF 服务

发布于 2024-09-10 10:54:29 字数 1875 浏览 6 评论 0原文

我使用 axis 1.4 创建了一个 java 客户端来使用 WCF 服务。如果我使用 basicHttpBinding 则一切正常,但如果我使用 wsHttpBinding 则出现以下错误:-

Did not understand "MustUnderstand" header(s):{http://www.w3.org/2005/08/addressing}Action
AxisFault
 faultCode: {http://www.w3.org/2003/05/soap-envelope}MustUnderstand
 faultSubcode: 
 faultString: Did not understand "MustUnderstand" header(s):{http://www.w3.org/2005/08/addressing}Action
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.tempuri.WSHttpBinding_IService1Stub.getData(WSHttpBinding_IService1Stub.java:171)
    at Mytes.main(Mytes.java:14)

    {http://xml.apache.org/axis/}hostname:2207A-H7-SITA

Did not understand "MustUnderstand" header(s):{http://www.w3.org/2005/08/addressing}Action
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.tempuri.WSHttpBinding_IService1Stub.getData(WSHttpBinding_IService1Stub.java:171)
    at Mytes.main(Mytes.java:14)

请让我知道如何解决此错误。谢谢。

I have created a java client for consuming WCF service using axis 1.4. If I use basicHttpBinding than everything works fine, but if I use wsHttpBinding than I am getting following error:-

Did not understand "MustUnderstand" header(s):{http://www.w3.org/2005/08/addressing}Action
AxisFault
 faultCode: {http://www.w3.org/2003/05/soap-envelope}MustUnderstand
 faultSubcode: 
 faultString: Did not understand "MustUnderstand" header(s):{http://www.w3.org/2005/08/addressing}Action
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.tempuri.WSHttpBinding_IService1Stub.getData(WSHttpBinding_IService1Stub.java:171)
    at Mytes.main(Mytes.java:14)

    {http://xml.apache.org/axis/}hostname:2207A-H7-SITA

Did not understand "MustUnderstand" header(s):{http://www.w3.org/2005/08/addressing}Action
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.tempuri.WSHttpBinding_IService1Stub.getData(WSHttpBinding_IService1Stub.java:171)
    at Mytes.main(Mytes.java:14)

Pls let me know how can I resolve this error. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

执笏见 2024-09-17 10:54:29

当您使用 Axis 为 WCF 服务生成代理时,它会生成自动设置 http://www.w3.org/2005/08/addressingMustUnderstand 标头的存根code>

下面的代码将 MustUnderstand 标志重置回 false。对于正在调用的方法。我今天遇到了类似的问题,并且能够使用此处发布的代码解决

//maybe someother service stub,i show you a case
    CommentWcfServiceLocator locator =new CommentWcfServiceLocator();
    WSHttpBinding_ICommentServiceStub stub;
    try {       
    //get a stub and set service url
    stub = (WSHttpBinding_ICommentServiceStub)   locator.getWSHttpBinding_ICommentService(new         java.net.URL("http://www.google.com/CommentWcfService.svc"));

    // the key is here , importantest!!! follow this
    // set action, action path,you can find in your java code
    SOAPHeaderElement action = new SOAPHeaderElement(new QName("wsa:Action"),     "http://tempuri.org/ICommentService/GetCommentSummaryByHotelId");
    SOAPHeaderElement to = new SOAPHeaderElement(new QName("wsa:To"),
    stub._getProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY));
        action.setActor(null);
        action.setNamespaceURI("http://www.w3.org/2005/08/addressing");
        to.setActor(null);
        to.setNamespaceURI("http://www.w3.org/2005/08/addressing");
         // set header
                stub.setHeader(action);
        stub.setHeader(to);
                // must set this property
        stub._setProperty(Call.CHECK_MUST_UNDERSTAND, Boolean.FALSE);
            stub.getCommentSummaryByHotelId("","02201158", 0);
    } 
catch(Exception EX){}

我发现 这篇关于 MustUnderstand 的文章非常有帮助。

When you use Axis to generate proxy for a WCF service, it generates the stub that automatically sets the MustUnderstand header for http://www.w3.org/2005/08/addressing

The code below resets the MustUnderstand flag back to false. for the method being invoked. I had a similar issue today and was able to resolve using the code that's posted here

//maybe someother service stub,i show you a case
    CommentWcfServiceLocator locator =new CommentWcfServiceLocator();
    WSHttpBinding_ICommentServiceStub stub;
    try {       
    //get a stub and set service url
    stub = (WSHttpBinding_ICommentServiceStub)   locator.getWSHttpBinding_ICommentService(new         java.net.URL("http://www.google.com/CommentWcfService.svc"));

    // the key is here , importantest!!! follow this
    // set action, action path,you can find in your java code
    SOAPHeaderElement action = new SOAPHeaderElement(new QName("wsa:Action"),     "http://tempuri.org/ICommentService/GetCommentSummaryByHotelId");
    SOAPHeaderElement to = new SOAPHeaderElement(new QName("wsa:To"),
    stub._getProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY));
        action.setActor(null);
        action.setNamespaceURI("http://www.w3.org/2005/08/addressing");
        to.setActor(null);
        to.setNamespaceURI("http://www.w3.org/2005/08/addressing");
         // set header
                stub.setHeader(action);
        stub.setHeader(to);
                // must set this property
        stub._setProperty(Call.CHECK_MUST_UNDERSTAND, Boolean.FALSE);
            stub.getCommentSummaryByHotelId("","02201158", 0);
    } 
catch(Exception EX){}

I found the this post on MustUnderstand veru helpful.

灰色世界里的红玫瑰 2024-09-17 10:54:29

BasicHttpBinding 或 webHttpBinidng(REST 服务)是与非 Microsoft 技术交互的唯一选项。
BasicHttpBinding 是唯一支持 Basic Profile 1.1 互操作性的绑定。

请浏览以下链接,看看它们是否可以帮助您了解基本的出价和 ws 出价。

http://www.devproconnections。 com/article/net-framework2/choosing-the-right-web-service-binding.aspx

链接

BasicHttpBinding or webHttpBinidng (REST services) are the only option to interact with non-microsoft technologies.
BasicHttpBinding is only binding which supports the Basic Profile 1.1 for interoperability.

Please go through below links and see if they can help you out to understand basic and ws bidning.

http://www.devproconnections.com/article/net-framework2/choosing-the-right-web-service-binding.aspx

Link

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文