Category SOAP

Apache CXF with Spring: How to add HTTP headers to a SOAP request using a custom CXF interceptor?


Let’s assume that we want to make a SOAP call to a service at http://localhost:8080/samplewebservices/echoserviceinterface, and it requires that we add an API / Access token as a HTTP header, we can do it this way: Assumptions Endpoint: http://localhost:8080/samplewebservices/echoserviceinterface Service Interface: singz.ws.test.interface.EchoService ACCESS_TOKEN: 046b6c7f-0b8a-43b9-b35d-6489e6daee91 (HTTP Header) Spring Application Context Configuration Custom Interceptor to add HTTP […]

Using .NET v2.0 generated WSDLs with JAX-WS: How to resolve “A class/interface with the same name “XXXX” is already in use. Use a class customization to resolve this conflict”?


I’ve noticed an issue in WSDLs generated by .NET 2.0 apps: some of the element(s) and their corresponding complextype definitions have same name. If you happen to generate JAX-WS portable artifacts (see below) from one such WSDL for your project (during technology migration etc. and you don’t want the consumers who use this WSDL to […]

Apache CXF: How to add custom HTTP headers to a web service request?


HTTP header fields are components of the message header of requests and responses in the Hypertext Transfer Protocol (HTTP). They define the operating parameters of an HTTP transaction, carry information about the client browser, the requested page, the server and more. Here’s how the HTTP headers can be added to your web service calls made […]

How to resolve java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors error in axis2?


I was getting this error (see below) in one of our axis2 based web service, and this is what I did to resolve it. org.apache.axis2.AxisFault: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:83) … Caused by: com.ctc.wstx.exc.WstxIOException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: […]

Resolving SOAPFaultException caused by com.ctc.wstx.exc.WstxUnexpectedCharException


If you’re using any of these for Web Services – Axis2, CXF etc. – that internally makes use of Woodstox XML processor (wstx), and getting an exception like this during webservice calls, the problem is that the wstx tokenizer/parser encountered unexpected (but not necessarily invalid per se) character; character that is not legal in current […]

Java Web Services: SOAP over SSL – CXF Framework


CXF Service Interface – CalculationServerIfc.java Let’s assume that the wsdl is accessible @ https://localhost:8443/calculationserver/CalculationServerImpl?wsdl CXF Client Implementation client-config.xml TestCXFCalcService.java Now, if we run this program, it’ll throw an exception. What’s the quick solution for this issue? 1. We’ve to disable CN (Server Certificate’s Common Name) check in the code 2. We’ve to trust all certificates […]