• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Axis Client Headers

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic