Empty SOAPAction Apache cxf

1.4k views Asked by At

I'm creating a soap client using apache cxf.I used a network hook capture the data and find out in Http header SOAPAction is empty

SOAPAction : ""

Below is the code

 URL wsdlurl=SOAPWebServiceTransport.class.getClassLoader().
        getResource("my.wsdl");
OnlinePort service= new OnlinePortService(wsdlurl).getOnlinePortPort();
Client proxy = ClientProxy.getClient(service);

// Provides WS-Security
WSS4JOutInterceptor wss4jOut = new WSS4JOutInterceptor();
wss4jOut.setProperty("action", "UsernameToken");
wss4jOut.setProperty("user", userName);
wss4jOut.setProperty("passwordType", "PasswordText");
wss4jOut.setProperty("password", password);
wss4jOut.setProperty(WSHandlerConstants.ADD_UT_ELEMENTS,
        WSConstants.NONCE_LN + " " + WSConstants.CREATED_LN);
wss4jOut.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, ServerPasswordCallback.class.getName());


proxy.getEndpoint().getOutInterceptors().add(wss4jOut);
    setConduitProperties((HTTPConduit) proxy.getConduit(),url);

In the setConduitProperties I'm just setting some http properties. While investigating this issue I found a work around

Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("SOAPAction", Arrays.asList("myPrefix:mySoapMethod"));
proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);

But the problem is that if I have more than one method then in the Http header its putting all the method

SOAPAction : "myPrefix:mySoapMethod,myPrefix:mySoapMethod2"

Is there any better solution to handle this?

1

There are 1 answers

0
Ondrej Burkert On

I would suggest to set the SOAPAction header per request. Otherwise, the server is not be able to tell which method do you want to invoke.