wood burning stoves 2.0*
The moose likes Web Services and the fly likes Axis Client Headers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis Client Headers" Watch "Axis Client Headers" New topic
Author

Axis Client Headers

Mike Litherland
Ranch Hand

Joined: Aug 12, 2004
Posts: 31
Hi,

I've created client stubs for a SOAP service using the Axis WSDL2Java program. With the '-a' switch it produces a stub for the headers that the service requires. The problem that I have is that there doesn't appear to be a way to tell your client program to use the header object you create. I've found some hints online that tell you how to create a header without using the stub code, but it seems there really ought to be a way.

Has anybody overcome this obstacle?

Thanks,
Ray Thomas
Greenhorn

Joined: Feb 24, 2005
Posts: 7
Even though this question was posted quite a while back, I just saw it while searching for something else so here's an answer:

Supposing that the class generated for the header info is MyHeaderType and the generated stub class (MyWebServiceStub) instance is assigned to a variable named binding, then:

MyHeaderType header = new MyHeaderType("param1", "param2", "paramEtc");
binding.addHeader("", "urn:MyWebServiceNamespace", header);

Just couldn't stand to see a question without an answer. Hope my answer works for somebody besides me.
Mark Newton
Ranch Hand

Joined: Jan 31, 2006
Posts: 129
Hi,

Just wanted to say thanks to both of you guys - I had the same problem, and hadn't even found the -a switch, so that was helpful in itself!

I actually needed to use a slightly different solution from the one Ray suggested, and I also needed a slight intellectual leap, which wasn't immediately obvious from his answer, so I'll show my solution here, just in case:

As with Ray, my class generated for the header info will be MyHeaderType, and the instance of my generated Stub class is binding.

I actually had to cast binding, and the relevant line reads:


Where http://.../... represents the namespace of the WSDL, tns:MyHeaderType is the name of the type required in my header (taken from the WSDL), and header is an instance of MyHeaderType.

Not sure about the difference between my setHeader(), and Ray's addHeader() methods, but I couldn't find an addHeader() method, and setHeader() works just fine!

Hope this is helpful to someone.
David.
 
jQuery in Action, 2nd edition
 
subject: Axis Client Headers