You could likely do something like:


public class StringHeader extends Header {
     private static final JAXBDataBinding DATABINDING 
         = new JAXBDataBinding(JAXBContext.newInstance(String.class));

     public StringHeader(JAXBElement<String> v) {
         super(v.getName(), v.getValue(), DATABINDING);
     }
}


and then do:

headers.add(new StringHeader(f.createUserName("xxxxxxx")));
…..


Dan





On 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

-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to