You might want to look at Glen Mazza's blog - he has number of extremely
helpful tutorials including some on SOAP headers  (using Handlers).  Your
generated objects don't require knowledge of the SOAP Header elements.

http://www.jroller.com/gmazza/entry/blog_article_index

http://www.jroller.com/gmazza/entry/jaxws_handler_tutorial  - Adding JAX-WS
handlers to web services and SOAP
clients<http://www.jroller.com/gmazza/entry/jaxws_handler_tutorial>
 *(June 2012) *


Hope this helps.

On Thu, Oct 18, 2012 at 3:06 PM, James Carr <[email protected]> wrote:

> Hi all,
>
> I generated soap stubs with wsdl2java and I am using JAX-WS. The
> service I need to call requires soap:header elements to be set but
> these aren't exposed in the generated objects anywhere.
>
> However... they are in the ObjectFactory generated for the elements.
> Specifically:
>
>     @XmlElementDecl(namespace =
> "http://www.example.com/services/loginservice";, name =
> "ClientAccessKey")
>     public JAXBElement<String> createClientAccessKey(String value) {
>         return new JAXBElement<String>(_ClientAccessKey_QNAME,
> String.class, null, value);
>     }
>
> Currently the only way I could figure out how to do this is by doing this:
>
>         List<Header> headers = new ArrayList<Header>();
>
>                 JAXBElement<String> userName = f.createUserName("xxxxxxx");
>                 JAXBElement<String> password =
> f.createPassword("xxxxxxxxxxxxx");
>                 JAXBElement<String> accessKey =
> f.createUserAccessKey("xxxxxx");
>                 JAXBElement<String> clientKey =
> f.createClientAccessKey("xxxxxxxxxxxx");
>
>                 headers.add(new Header(userName.getName(),
> userName.getValue(), new
> JAXBDataBinding(String.class)));
>                 headers.add(new Header(password.getName(),
> password.getValue(), new
> JAXBDataBinding(String.class)));
>                 headers.add(new Header(accessKey.getName(),
> accessKey.getValue(),
> new JAXBDataBinding(String.class)));
>                 headers.add(new Header(clientKey.getName(),
> clientKey.getValue(),
> new JAXBDataBinding(String.class)));
>
>
>                 proxy.getRequestContext().put(Header.HEADER_LIST, headers);
>
> I don't like it... is there a better way?
>
>
> Thanks,
> James
>



-- 
*Mark
*

Reply via email to