WCF web service, Java web client, MustUnderstand headers incomprehensible?

I host a WCF web service with the following WSDL (a simple service using wsHttpBinding and SSL for transport security):

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="MagicEightBallService" targetNamespace="http://tempuri.org/"> <wsp:Policy wsu:Id="WSHttpBinding_TransportSecurity_IMagicEightBallService_policy"> <wsp:ExactlyOne> <wsp:All> <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> <wsp:Policy> <sp:TransportToken> <wsp:Policy> <sp:HttpsToken RequireClientCertificate="false"/> </wsp:Policy> </sp:TransportToken> <sp:AlgorithmSuite> <wsp:Policy> <sp:Basic256/> </wsp:Policy> </sp:AlgorithmSuite> <sp:Layout> <wsp:Policy> <sp:Strict/> </wsp:Policy> </sp:Layout> </wsp:Policy> </sp:TransportBinding> <wsaw:UsingAddressing/> </wsp:All> </wsp:ExactlyOne> </wsp:Policy> <wsdl:types> <xsd:schema targetNamespace="http://tempuri.org/Imports"> <xsd:import schemaLocation="http://my.local.domain.name/MagicEightBall/MagicEightBallService.svc?xsd=xsd0" namespace="http://tempuri.org/"/> <xsd:import schemaLocation="http://my.local.domain.name/MagicEightBall/MagicEightBallService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/> </xsd:schema> </wsdl:types> <wsdl:message name="IMagicEightBallService_GetAdvice_InputMessage"> <wsdl:part name="parameters" element="tns:GetAdvice"/> </wsdl:message> <wsdl:message name="IMagicEightBallService_GetAdvice_OutputMessage"> <wsdl:part name="parameters" element="tns:GetAdviceResponse"/> </wsdl:message> <wsdl:portType name="IMagicEightBallService"> <wsdl:operation name="GetAdvice"> <wsdl:input wsaw:Action="http://tempuri.org/IMagicEightBallService/GetAdvice" message="tns:IMagicEightBallService_GetAdvice_InputMessage"/> <wsdl:output wsaw:Action="http://tempuri.org/IMagicEightBallService/GetAdviceResponse" message="tns:IMagicEightBallService_GetAdvice_OutputMessage"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="WSHttpBinding_TransportSecurity_IMagicEightBallService" type="tns:IMagicEightBallService"> <wsp:PolicyReference URI="#WSHttpBinding_TransportSecurity_IMagicEightBallService_policy"/> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="GetAdvice"> <soap12:operation soapAction="http://tempuri.org/IMagicEightBallService/GetAdvice" style="document"/> <wsdl:input> <soap12:body use="literal"/> </wsdl:input> <wsdl:output> <soap12:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="MagicEightBallService"> <wsdl:port name="WSHttpBinding_TransportSecurity_IMagicEightBallService" binding="tns:WSHttpBinding_TransportSecurity_IMagicEightBallService"> <soap12:address location="https://localhost/MagicEightBall/MagicEightBallService.svc"/> <wsa10:EndpointReference> <wsa10:Address> https://localhost/MagicEightBall/MagicEightBallService.svc </wsa10:Address> </wsa10:EndpointReference> </wsdl:port> </wsdl:service> </wsdl:definitions> 

Why am I getting errors when I try to use this in Java? When I try to use it with Axis2 / Java, I get an error:

 org.apache.axis2.AxisFault: Must Understand check failed for header http://www.w3.org/2005/08/addressing : Action 

And when I try to use JAX-WS, I get an error message:

 javax.xml.ws.soap.SOAPFaultException: MustUnderstand headers:[{http://www.w3.org/2005/08/addressing}Action] are not understood 

So far, I have not had any success with any of them, and I'm not sure if the fix should be applied to the server or client.

(see the related question I posted for more details, including WCF Web.config).

+4
source share
4 answers

Duration:

 ServiceClient sc = stub._getServiceClient(); sc.engageModule("addressing"); 

The addressing module is connected, eliminating this problem.

+4
source

I know the message is outdated, but someone may still run into this problem.

I am using JAX-WS and I had the same problem. After reading https://jax-ws.java.net/jax-ws-21-ea3/docs/wsaddressing.html#On_the_client_side I found a solution that worked for me.

The code was broken into the following line:

 IFooService service = new FooService().getWSHttpBindingIFooService(); 

I have done the following:

 IFooService service = new FooService().getWSHttpBindingIFooService(new javax.xml.ws.soap.AddressingFeature()); 

What is it.

+3
source

also add the addressing .mar and soapmonitor.mar to your library path.

+1
source

I had the same problem too.

In my case, the webservice WSDL was created using WCF in .net, and we consume it from the JAVA side. After several attempts, I noticed that the corresponding header is missing from the web service. I asked my dotnet command to add the port name to the webservice. This port name is just a common name in a web service. This was necessary because on the JAVA side, we need the port type and port name for the actual access to the web service.

Try adding below lines on the .net side inside the service, and then try using them on the JAVA side.

 [ServiceContract(Namespace = "BookStockWebService", Name = "BookStock")] [ServiceBehavior(Namespace = "BookStockWebServiceport", Name = "BookStockPort")] 
+1
source

All Articles