0

I am trying to add a SOAP:Header with wss4j authentication for my outbound SOAP service.

Below is my WebServiceTemplate and interceptor configuration

<bean id="securityHeader"
    class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
    <property name="securementActions" value="UsernameToken" />
    <property name="securementUsername" value="uname" />
    <property name="securementPassword" value="password@123" />
    <property name="securementPasswordType" value="PasswordText" />
    <property name="securementUsernameTokenElements" value="Nonce Created" />
</bean>`

<bean id="webService" class="org.springframework.ws.client.core.WebServiceTemplate">
    <constructor-arg ref="messageFactory" />
    <property name="messageSender">
        <bean
            class="org.springframework.ws.transport.http.CommonsHttpMessageSender">
            <!-- <property name="credentials" ref="credentials" /> -->
        </bean>
    </property>
    <property name="interceptors">
    <list>
        <ref bean="securityHeader" />
    </list>
</property>
    <property name="defaultUri"
        value="https://test.test.com/ws/service/test" />        
    <property name="marshaller" ref="fmarshaller" />
    <property name="unmarshaller" ref="forwardunmarshaller" />
</bean>

But when the outbound call happens, its not adding the SOAP security header.webService.marshalSendAndReceive("http://localhost:8088/mockBinding",request);

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
prakash
  • 57
  • 2
  • 13
  • Can't see a problem here. Can you try if specifying the bean definition directly; (without a ref) works? – Bajal Sep 15 '15 at 01:25
  • Is the configured `WebServiceTemplate` actually the template you are using? – M. Deinum Sep 15 '15 at 06:11
  • Will there be an issue with the wss4j and spring version im using? – prakash Sep 15 '15 at 18:19
  • After removing the reference and adding the bean declaration within the interceptor property, I am getting this exception. org.springframework.messaging.MessageHandlingException: org.apache.axiom.soap.SOAPProcessingException: SOAP Envelope can not have children other than SOAP Header and Body – prakash Sep 15 '15 at 19:08
  • Can you please update your question with the Spring-WS and Axiom version you are using? – Andreas Veithen Sep 15 '15 at 19:17
  • Spring-WS version is 2.2.2.RELEASE and also I found spring-security-core-3.2.7.RELEASE.jar inside my war. Will this cause problem? – prakash Sep 15 '15 at 21:15

1 Answers1

0

Below changes did the trick for me.

  1. Changing the SOAP version to 1.1
  2. Defining the bean declaration inside interceptor instead of referencing it.
  3. Use a web service message callback.
prakash
  • 57
  • 2
  • 13