4
votes

I am using the CXF Web Client to call Soap Web Service.

WSDL2JAVA is used to generate Java Code from wsdl. There are information from the soap header but the generated code do not have method to access the header.

How can I get header information by the CXF Web Client?

2
I used apache cxf interceptor to get the information. I still do not know how to pass the header information to service. Also, I do not know whether it is a proper method.Ben Cheng

2 Answers

4
votes

try -exsh (true/false) as an option to wsdl2java

2
votes

wsdl2java generate java code based on wsdl provided because the wsdl is the data contract between the producer and consumer.

If the consumer would like to get header information. The best is that the wsdl contains methods to get header data.

If the wsdl did not describe it, special handling may be required. You may directly get the header information by the response or by interceptors.

My way is that the interceptor capture the header information and then throws fault exception. The method catch the exception and then get the header information. It seems a dirty way but work for me.