Setting a custom HTTP header dynamically with Spring-WS client

public class AddHttpHeaderInterceptor implements ClientInterceptor { public boolean handleFault(MessageContext messageContext) throws WebServiceClientException { return true; } public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException { TransportContext context = TransportContextHolder.getTransportContext(); HttpComponentsConnection connection =(HttpComponentsConnection) context.getConnection(); connection.addRequestHeader(“name”, “suman”); return true; } public boolean handleResponse(MessageContext messageContext) throws WebServiceClientException { return true; } } config: <bean id=”webServiceTemplate” class=”org.springframework.ws.client.core.WebServiceTemplate”> … <property name=”interceptors”> <list> … Read more

How to set timeout in Spring WebServiceTemplate

If you are using Spring Webservices 2.1.0 version, You can set timeout using HttpComponentsMessageSender. CommonsHttpMessageSender are deprecated and not recommended by Spring anymore. The way I have it implemented, I define my WebServiceTemplate to use HttpComponentsMessageSender. Values are in Milliseconds <bean id=”webServiceTemplate” class=”org.springframework.ws.client.core.WebServiceTemplate”> <property name=”defaultUri” value=”${endpoint.url}” /> <property name=”marshaller” ref=”marshaller” /> <property name=”unmarshaller” ref=”unmarshaller” /> … Read more

JAXB :Need Namespace Prefix to all the elements

Solved by adding @XmlSchema( namespace = “http://www.example.com/a”, elementFormDefault = XmlNsForm.QUALIFIED, xmlns = { @XmlNs(prefix=”ns1″, namespaceURI=”http://www.example.com/a”) } ) package authenticator.beans.login; import javax.xml.bind.annotation.*; in package-info.java Took help of jaxb-namespaces-missing : Answer provided by Blaise Doughan

Which framework is better CXF or Spring-WS? [closed]

About Apache CXF: CXF supports several standards including SOAP, the WSI Basic Profile, WSDL, WS-Addressing, WS-Policy, WS-ReliableMessaging, WS-Security, WS-SecurityPolicy, and WS-SecureConversation. Apache CXF offers both contract-last (starting with Java) and Contract-first (starting with the WSDL) approaches. Apache CXF implements JAX-WS and JAX-RS. About Spring WS: Spring WS offers “only” contract-first, starting from an XSD Schema. … Read more