Jax-ws : Java SOAP exception :MustUnderstand headers:[{http://www.w3.org/2005/08/addressing}Action
Asked Answered
A

6

7

I am using Jax-ws to implement client application for Onvif IP camera, I am sending a request to camera to create PullPointSubscription ,It seems the camera understands the request and process the request and send the correct response , but the client jax-ws code throws an exception

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

I do not understand what is the problem exactly? Anybody can explain what the problem is and how to solve it?

The exception details

an 29, 2012 11:43:48 AM com.sun.xml.ws.protocol.soap.MUTube getMisUnderstoodHeaders
INFO: Element not understood={http://www.w3.org/2005/08/addressing}Action
javax.xml.ws.soap.SOAPFaultException: MustUnderstand headers:[{http://www.w3.org/2005/08/addressing}Action] are not understood
    at com.sun.xml.ws.protocol.soap.MUTube.createMUSOAPFaultException(MUTube.java:148)
    at com.sun.xml.ws.protocol.soap.ClientMUTube.processResponse(ClientMUTube.java:109)
    at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:651)
    at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:600)
    at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:585)
    at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:482)
    at com.sun.xml.ws.client.Stub.process(Stub.java:323)
    at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:161)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:113)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:93)
    at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:144)
    at $Proxy46.createPullPointSubscription(Unknown Source)
    at Test.SubInEventLast(Test.java:173)
    at Test.main(Test.java:139)

The request soap message is

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
    <S:Body>
    <ns6:CreatePullPointSubscription xmlns:ns2="http://www.w3.org/2005/08/addressing" 
        xmlns:ns3="http://docs.oasis-open.org/wsn/b-2" 
        xmlns:ns4="http://docs.oasis-open.org/wsrf/bf-2" 
        xmlns:ns5="http://docs.oasis-open.org/wsn/t-1" 
        xmlns:ns6="http://www.onvif.org/ver10/events/wsdl" 
        xmlns:ns7="http://www.onvif.org/ver10/schema" 
        xmlns:xmime="http://www.w3.org/2005/05/xmlmime" 
        xmlns:ns9="http://www.w3.org/2004/08/xop/include" 
        xmlns:ns10="http://docs.oasis-open.org/wsrf/r-2">
        <ns6:Filter>
            <ns3:TopicExpression xmlns="http://docs.oasis-open.org/wsn/b-2" 
                xmlns:tns1="http://www.onvif.org/ver10/topics" 
                Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet">
                tns1:Device
            </ns3:TopicExpression>
        </ns6:Filter>
        <ns3:InitialTerminationTime>PT1M</ns3:InitialTerminationTime>
    </ns6:CreatePullPointSubscription>
    </S:Body>
</S:Envelope>

and this is the soap response

              <?xml version="1.0" encoding="UTF-8"?>
                <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" 
                    xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" 
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                    xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" 
                    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
                    xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
                    xmlns:wsa5="http://www.w3.org/2005/08/addressing" 
                    xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" 
                    xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" 
                    xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" 
                    xmlns:tt="http://www.onvif.org/ver10/schema" 
                    xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" 
                    xmlns:tan1="http://www.onvif.org/ver10/analytics/wsdl/RuleEngineBinding" 
                    xmlns:tan="http://www.onvif.org/ver10/analytics/wsdl" 
                    xmlns:tan2="http://www.onvif.org/ver10/analytics/wsdl/AnalyticsEngineBinding" 
                    xmlns:tds="http://www.onvif.org/ver10/device/wsdl" 
                    xmlns:tev1="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" 
                    xmlns:tev2="http://www.onvif.org/ver10/events/wsdl/EventBinding" 
                    xmlns:tev3="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" 
                    xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" 
                    xmlns:tev4="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" 
                    xmlns:tev="http://www.onvif.org/ver10/events/wsdl" 
                    xmlns:timg="http://www.onvif.org/ver10/imaging/wsdl" 
                    xmlns:tptz="http://www.onvif.org/ver10/ptz/wsdl" 
                    xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
                     xmlns:ter="http://www.onvif.org/ver10/error" 
                     xmlns:tns1="http://www.onvif.org/ver10/topics" 
                     xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
                    <SOAP-ENV:Header>
                        <wsa5:Action SOAP-ENV:mustUnderstand="true">http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/CreatePullPointSubscriptionResponse</wsa5:Action>
                    </SOAP-ENV:Header>
                    <SOAP-ENV:Body>
                         <tev:CreatePullPointSubscriptionResponse>
                            <tev:SubscriptionReference>
                            <wsa5:Address>http://192.168.0.151/onvif/services</wsa5:Address>
                            <wsa5:ReferenceParameters><dom0:SubscriptionId xmlns:dom0="http://www.axis.com/2009/event">3</dom0:SubscriptionId>
                            </wsa5:ReferenceParameters>
                        </tev:SubscriptionReference>
                        <wsnt:CurrentTime>2010-10-27T09:11:42Z</wsnt:CurrentTime>
                        <wsnt:TerminationTime>2010-11-24T09:11:42Z</wsnt:TerminationTime></tev:CreatePullPointSubscriptionResponse>
                     </SOAP-ENV:Body>
                 </SOAP-ENV:Envelope>
Annates answered 29/1, 2012 at 17:47 Comment(2)
I am afraid that the namespace you refer to (WS-Addressing 1.0) is not supported by JAX-WS. Were there any warnings by wsimport when you've generated your JAX-WS artefacts?Jervis
I'm having the same problem. When I've runned wsimport, the following warning was shown: unknown extensibility element or attribute "EndpointReference" (in namespace "w3.org/2005/08/addressing")Astolat
L
8

I had this same issue with a particular device and it took me a few days of searching and trial and error to come up with a solution (almost purely by chance). I was able to solve this issue by adding a custom Handler to the port. The handler only needs to provide the QName for the WS-Addressing Action header (it doesn't need to do anything when handleMessage is called).

This is what worked for me:

public class ActionHandler implements SOAPHandler<SOAPMessageContext> 
{   
    @Override
    public boolean handleMessage(SOAPMessageContext context) 
    {
        // Auto-generated method stub
        return true;
    }

    @Override
    public boolean handleFault(SOAPMessageContext context) 
    {
        // Auto-generated method stub
        return false;
    }

    @Override
    public void close(MessageContext context) 
    {
        // Auto-generated method stub
    }

    @Override
    public Set<QName> getHeaders() 
    {
        Set<QName> set = new HashSet<QName>();
        // Make sure the '[{http://www.w3.org/2005/08/addressing}]Action' header 
        // is handled in case the device set the 'MustUnderstand' attribute to '1'
        set.add(new QName("http://www.w3.org/2005/08/addressing", "Action"));
        return set;
    }   
}

Then add the Handler to binding's handler chain:

BindingProvider bindingProvider = (BindingProvider) eventPortType;      
final Binding binding = bindingProvider.getBinding();

List<Handler> handlerList = binding.getHandlerChain();
if (handlerList == null)
    handlerList = new ArrayList<Handler>();

handlerList.add(new ActionHandler());

binding.setHandlerChain(handlerList);
Levigate answered 2/10, 2013 at 18:23 Comment(0)
B
8

In my case, this helps :

getPort(QName portName,
            Class<T> serviceEndpointInterface, WebServiceFeature... features)

passing new javax.xml.ws.soap.AddressingFeature() as WebServiceFeature .

Boethius answered 11/10, 2016 at 13:43 Comment(0)
M
4

Solution to FIX

  • "MustUnderstand headers:[{http://www.w3.org/2005/08/addressing}Action] are not understood"

  • "The server sent HTTP status code 415: Cannot process the message because the content type 'application/soap+xml;charset="utf-8";"

Use NetBeans version 7.1 or higher to generate Web Service Client.

( NetBeans will use javax.xml.ws.Service)

So FIX some things in the Code:

When you instantiate your client service, you need pass the "feature" param.

com.sun.xml.internal.ws.developer.BindingTypeFeature featureB = new BindingTypeFeature(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING);
javax.xml.ws.soap.AddressingFeature featureA = new AddressingFeature();

IGeneratedServiceEV servico = new GeneratedService()
.getBasicHttpBindingGeneratedServiceEV(featureA,featureB);

The most important thing is that you have to create a service using the "feature": "javax.xml.ws.Service.getPort(wsdlLocation, featureA, FeatureB)"

After you can migrate the code to another IDE like "Eclipse".

Misguidance answered 26/10, 2016 at 19:15 Comment(1)
Adding features helped. Thanks!Illusionism
P
1

yes,I solved it

WSService service  = new WSService();
IWSService wcf = service.getWSHttpBindingIWSService(new AddressingFeature(true));
Plough answered 8/3, 2019 at 9:6 Comment(0)
L
0

Another way to solve this issue is adding the "-XadditionalHeaders" argument to the wsimport command. This will add the request/response header parameters to the service method.

wsimport HelloWorld.wsdl -keep -d ./src/main/java -p com.trial.helloworld -XadditionalHeaders
Lion answered 20/2, 2015 at 9:34 Comment(0)
C
0

If you are using one of the annotations @WebService, @WebServiceProvider or @WebServiceRef, then it can be solved by also adding the @Addressing annotation from javax.xml.ws.soap.

Census answered 10/6, 2021 at 11:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.