WAJSBERG Julien RD-BIZZ wrote:

M Litherland a écrit :

Hi all,

I'm new to Axis and I am trying to create a SOAP client to communicate with a vendor. They have supplied me with the WSDL and I ran WSDL2Java against it to create my stubs. There are custom headers, so I specified the '-a' option for WSDL2Java to produce a stub for the custom header as well.

My problem is that I don't know what to do with this custom header. I can create the object and populate it as need be, but how do I tell my code to use that header? The code is very simple - essentially these three lines:

MySoapLocator msl = new MySoapLocator();
MySoap ms = msl.getMySoap(new java.net.URL(URL));
ms.send(message);

I would expect to be able to do something like this:

ms.setHeader(myHeaderObject);


You can do that :

       MyService service = new MyServiceLocator();
       MyPortType client = service.getService();
            /* header */
       Stub s = (Stub) client;
       s.setHeader("namespace", "element name", new MyHeader(args));

and then continue on calling the methods as usually.
"namespace" is the namespace of the header;
"element name" is the element name of the header (I'm pretty logical here :)
MyHeader is the stub class created by Axis.


However, I couldn't find a way to make Axis use automatically the namespace and element name specified in the WSDL.

Hi,

Thanks for the helpful advice. This worked fine. The reason I didn't notice it before was that I accidentally cast it to javax.xml.rpc.Stub instead of the Axis version, which doesn't have methods to deal with headers.

Thanks again, everyone.
Mike

Reply via email to