11

Hi I create code for consume SOAP service,

For Authentication Header I used Wss4jSecurityInterceptor for set Header information.

I am getting fail response like below

 Exception in thread "main" org.springframework.ws.soap.client.SoapFaultClientException: Required element {http://www.w3.org/2005/08/addressing}Action is missing

My Configuration code as below

@Configuration
public class SoapClientConfig {

    @Bean
    public Jaxb2Marshaller marshaller() {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
        marshaller.setContextPath("com.xyz.client");
        marshaller.setCheckForXmlRootElement(false);
        return marshaller;
    }

    @Bean
    public MyClient myClient(Jaxb2Marshaller marshaller) throws Exception {
        MyClient client = new MyClient();
        client.setDefaultUri("https://localhost:8080/ws/service");
        client.setMarshaller(marshaller);
        client.setUnmarshaller(marshaller);

        ClientInterceptor[] interceptors = new ClientInterceptor[] {securityInterceptor()};

        client.setInterceptors(interceptors);
        return client;
    }

    @Bean
    public Wss4jSecurityInterceptor securityInterceptor() {
        Wss4jSecurityInterceptor wss4jSecurityInterceptor = new Wss4jSecurityInterceptor();
        wss4jSecurityInterceptor.setSecurementActions("UsernameToken");
        wss4jSecurityInterceptor.setSecurementMustUnderstand(true);
        wss4jSecurityInterceptor.setSecurementPasswordType("PasswordText");
        wss4jSecurityInterceptor.setSecurementUsername("XXXXXXXXXXX");
        wss4jSecurityInterceptor.setSecurementPassword("XXXXXXXX");
        return wss4jSecurityInterceptor;
    }
}

Can anyone suggest me what I am missing?

If I try from SOAPUI its working fine. If I set WS-Addressing=false from SOAPUI also giving me same error, So Issue with set WS-Addressing property with above code. How can I?

buræquete
  • 14,226
  • 4
  • 44
  • 89
Piyush Ghediya
  • 1,754
  • 1
  • 14
  • 17
  • I got the solution of above issue here... https://stackoverflow.com/questions/43974784/remote-soap-web-service-keeps-breaking-connection/44154445#44154445 – Piyush Ghediya May 25 '17 at 10:42

2 Answers2

6

Do you use WebServiceTemplate to send the request? If yes, you can do something like :

ActionCallback callback = new ActionCallback(
                    new URI("action uri"));

Here you should provide actual uri location of action instead "action uri". Then, do

getWebServiceTemplate().marshalSendAndReceive(request, callback)
S. Stas
  • 800
  • 4
  • 8
  • My SOAP Header already contain this Action info. Also addressing property also there, then also I am getting addressing issue –  Mar 29 '17 at 09:31
  • So could you post the whole code dealing with request construction andsending? – S. Stas Mar 29 '17 at 10:54
  • 1
    The issue is weird that its depend upon Sequence of Action define.If I define Action before Security element it shows error. If I define Action after Security Its works. – Piyush Ghediya Apr 01 '17 at 07:24
  • I don't find a way to set the "wsa:To" header on the client, when this URL is different to the endpoint. – Maske Feb 17 '21 at 14:34
0

Long time before worked on populating SOAP Header with dynamic value, for that you need to work on constructing the xml nodes using callback object...WebServiceMessageCallback

http://docs.spring.io/spring-ws/site/reference/html/client.html#d5e1848

In my scenario I need to construct the node using QName (Java) Node by Node.