I would like to ask a question about @UsesJAXBContext annotation in jax-ws. I'm trying to get it to work on the client side, but I probably missed something. Here is my case:
I have a web service with an operation:
@WebMethod(operationName = "putToQueue")
public boolean put(@WebParam(name = "queueName") String queueName, @WebParam(name = "element") Object element) {
return queues.get(queueName).offer(element);
}
On the client side, I created QueueService and Queue (port) ... and other things ... [respones requests. In this case, it does not matter.] I would like to let the user define an object that he / she can queue. However, to invoke the put (...) operation, I need to bind the object (which I'm trying to send) to JAXBContext. I could do this
@XmlSeeAlso at the top of the generated queue of queues [I tried this and it works]. However, I need a more general solution that helps me bind the object at runtime. I thought that I could create the annotation @QueueMessage and ClientJAXBContextFactory and add selected classes to the class when I create it.
public class ClientJAXBContextFactory implements JAXBContextFactory {
@Override
public JAXBRIContext createJAXBContext(SEIModel seim, List<Class> classes, List<TypeReference> references) throws JAXBException {
Reflections reflections = new Reflections("");
Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(QueueMessage.class);
classes.addAll(annotated);
return JAXBContextFactory.DEFAULT.createJAXBContext(seim, classes, references);
}
}
@UsesJAXBContext .
@WebService(name = "Queue")
@UsesJAXBContext(ClientJAXBContextFactory.class)
public interface Queue {
...
}
createJAXBContext (...) , jax-w JAXBContextImpl.
:
http://weblogs.java.net/blog/jitu/archive/2008/08/control_of_jaxb.html
http://www.techques.com/question/1-5627173/Specify-JAXB-Packages-in-SLSB-and-JAX-WS
stackOverFlow. .
, ?
, ... @UsesJAXBContext . , .