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:-
我已经创建了一个使用axis 1.4使用WCF服务的java客户机。如果我使用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)
Pls let me know how can I resolve this error. Thanks.
请告诉我怎样才能解决这个问题。谢谢。
2 个解决方案
#1
3
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
当您使用Axis为WCF服务生成代理时,它将生成存根,该存根将自动设置http://www.w3.org/2005/08/addressing的MustUnderstand头
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
下面的代码将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){}
I found the this post on MustUnderstand veru helpful.
我发现MustUnderstand veru上的这篇文章很有帮助。
#2
-2
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.
BasicHttpBinding或webHttpBinidng (REST services)是与非microsoft技术交互的惟一选项。BasicHttpBinding只是绑定,它支持基本概要1.1的互操作性。
Please go through below links and see if they can help you out to understand basic and ws bidning.
请浏览下面的链接,看看它们是否能帮助您理解basic和ws bidning。
http://www.devproconnections.com/article/net-framework2/choosing-the-right-web-service-binding.aspx
http://www.devproconnections.com/article/net-framework2/choosing-the-right-web-service-binding.aspx
http://geekswithblogs.net/claeyskurt/archive/2008/04/22/121508.aspx
http://geekswithblogs.net/claeyskurt/archive/2008/04/22/121508.aspx
#1
3
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
当您使用Axis为WCF服务生成代理时,它将生成存根,该存根将自动设置http://www.w3.org/2005/08/addressing的MustUnderstand头
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
下面的代码将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){}
I found the this post on MustUnderstand veru helpful.
我发现MustUnderstand veru上的这篇文章很有帮助。
#2
-2
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.
BasicHttpBinding或webHttpBinidng (REST services)是与非microsoft技术交互的惟一选项。BasicHttpBinding只是绑定,它支持基本概要1.1的互操作性。
Please go through below links and see if they can help you out to understand basic and ws bidning.
请浏览下面的链接,看看它们是否能帮助您理解basic和ws bidning。
http://www.devproconnections.com/article/net-framework2/choosing-the-right-web-service-binding.aspx
http://www.devproconnections.com/article/net-framework2/choosing-the-right-web-service-binding.aspx
http://geekswithblogs.net/claeyskurt/archive/2008/04/22/121508.aspx
http://geekswithblogs.net/claeyskurt/archive/2008/04/22/121508.aspx