Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8114377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:07:40+00:00 2026-06-06T03:07:40+00:00

i would like to ask a question about @UsesJAXBContext annotation in jax-ws. I try

  • 0

i would like to ask a question about @UsesJAXBContext annotation in jax-ws. I try to make it work on client side but I’m probably missing something. Here is my case:

I’ve got webservice with 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 generated QueueService and Queue (port)… and other stuff… [respones requests. In this case irrelevant.]
I would like to let user define object that he/she could put to queue. However to invoke operation put(…) I need bind object (that I try to send) into JAXBContext. I could do that by
@XmlSeeAlso in the top of the generated Queue stub [i tried this one and it works]. Nonetheless I need more generic solution that help me bind object at runtime.
I thought that I could create @QueueMessage annotation and ClientJAXBContextFactory and add marked class to the context when creating 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);
    }
}

Next i tried use @UsesJAXBContext on top of generated Queue.

@WebService(name = "Queue")
@UsesJAXBContext(ClientJAXBContextFactory.class)
public interface Queue {
...
}

But createJAXBContext(…) is not invoked and jax-ws just simply create his JAXBContextImpl.

I have read:

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

and some question on stackOverFlow. I would be grateful for advises.
Is it possible to implement idea presented in my question?

Also i might add that on the server side … @UsesJAXBContext works. But its important for me to make it work on the client side.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:07:41+00:00Added an answer on June 6, 2026 at 3:07 am

    Ok I could manage problem i was facing. Still i couldn’t use @UsesJAXBContext with client consuming the webservice. But i found that this annotations are tied to beans with post-fix Feature. So there is a class UsesJAXBContextFeature

    https://jax-ws.java.net/nonav/2.2.7/javadocs/com/sun/xml/ws/developer/UsesJAXBContextFeature.html

    and it could be passed as argument of port or service(service since jax-ws 2.2). I have got a little trouble with versions so i decided to generate class and use jax-ws 2.1. Now i just simply create port like this:

    new QueueService().getQueuePort(new UsesJAXBContextFeature(new ClientJAXBContextFactory()));
    

    And it works!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to ask a theoritical question about how some web sites work.
There are some discussions about the same question but I would like to ask
I know this is a weird question to ask, but I would like to
I would like to ask a question about correct way of canceling socket operations
I would like to ask a question about a new and large scale web
I would like to ask a question. Now i'm training about iPhone Programming. I'm
I would like to ask you a question about implementing mutual authentication with Kerberos,
I know this may sound like a weird question to ask but I would
I would like to ask a question about triggers. Let's say that I have
I would like to ask you a question about logging provided jars. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.