1

I want send SOAP headers using WSBindingProvider. I saw an example where it's used a JAXBRIContext to create headers but I don't understand how get an instance of this class. This is the example:

...    
HelloService helloService = new HelloService();
HelloPort port = helloService.getHelloPort();
WSBindingProvider bp = (WSBindingProvider)port;

bp.setOutboundHeaders(
  Headers.create(JAXBRIContext context, Object o) 
);
...

The method createInstance of JAXBRIContext take various parameter that I don't understand. This is the signature of the method:

public static JAXBRIContext newInstance(Class[] classes,
Collection<TypeReference> typeRefs,
Map<Class, Class> subclassReplacements,
String defaultNamespaceRemap,
boolean c14nSupport,
RuntimeAnnotationReader ar) throws JAXBException

Someone can explain me the parameter that I should pass to this method. Thanks everybody in advance and sorry for my english.

Mauro
  • 11
  • 2
  • JAXBRIContext isn't intended to be used in application code. Isn't there an example where the JDK javax.xml.bind.JAXBContext is used? – laune Aug 24 '14 at 18:01
  • @laune Thanks for your reply. I don't understand what you mean for "JAXBRIContext isn't intended to be used in application code", however this is the doc page where I saw the Headers.create method [link](https://jax-ws.java.net/jax-ws-20-fcs/arch/com/sun/xml/ws/api/message/Headers.html). And [here](http://grepcode.com/file/repo1.maven.org/maven2/com.sun.xml.bind/jaxb-impl/2.1.7/com/sun/xml/bind/api/JAXBRIContext.java#JAXBRIContext) there is the method signature for getting JAXBRIContext but I don't understand the input parameters. – Mauro Aug 24 '14 at 19:54
  • AsI said: it's a class below com.sun, and these aren't meant to be used in everyday application code; also note the comment "subject to change w.o. further notice". All of JAXB you are likely to need is available via javax.xml.bind. Why can't you use JAXBContext? – laune Aug 25 '14 at 06:42
  • And see this: http://stackoverflow.com/questions/1834826/it-is-a-bad-practice-to-use-suns-proprietary-java-classes – laune Aug 25 '14 at 06:44
  • @laune Actually in my application I use JAXBContext, but it's not much handy build SOAP headers. I use an HeaderHandler class where I construct the header piece by piece. With JAXBRIContext I thought I could use the objects generated by JAXB. However thanks for your help! – Mauro Aug 25 '14 at 19:47
  • The context is merely an entry point and an aggregation of the types to be used. Building an XML document in "unusual" ways is more of a marshaller issue. – laune Aug 26 '14 at 04:50

0 Answers0