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 499597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:00:06+00:00 2026-05-13T06:00:06+00:00

I have a JAX-RS web service (using jersey) that accepts a JAXB object as

  • 0

I have a JAX-RS web service (using jersey) that accepts a JAXB object as the request entity. When we get an error, we want to log the original xml string that was sent to us. Currently, I am just re-marshalling the JAXB object, but since we have several java enums in those classes, enum values that are not spelled correctly in the original xml string are lost, which is not acceptable for our purposes.

Does anyone know a way to get the request entity as both a string and JABX object? I would prefer not to write a custom MessageBodyReader and I would prefer to not try and get the MessageBodyReader for the JAXB if possible. You are free to use jersey-specific classes as well. We are using version 1.0.x.

  • 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-05-13T06:00:07+00:00Added an answer on May 13, 2026 at 6:00 am

    Turns out it isn’t that hard to do this with the JAX-RS API. Here’s what I did:

    @Path("/transactions")
    public class TestResource<X> {
    
        private Class<X> jaxbClass;
    
        @POST
        @Path("/{transaction-id}")
        @Consumes("application/xml")
        public Response processPost(@Context Providers providers, @Context HttpHeaders httpHeaders, @PathParam("transaction-id") final long transactionId,
                final String xmlString) throws WebApplicationException, IOException {
    
            MessageBodyReader<X> reader = providers.getMessageBodyReader(jaxbClass, null, null, MediaType.APPLICATION_XML_TYPE);
            InputStream entityStream = new ByteArrayInputStream(xmlString.getBytes());
            final X xmlObject = reader.readFrom(jaxbClass, null, null, MediaType.APPLICATION_XML_TYPE, httpHeaders.getRequestHeaders(), entityStream);
    
            //insert logic here
    
            return Response.ok().build();
        }
    }
    

    This will give you the xml as a string and as a JAXB object in just a few lines of code.

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

Sidebar

Related Questions

I have a JAX-RPC web service that I am attempting to consume using Spring.
I have an AXIS2/JAX-WS web service using a code first implementation (yes I know,
I have a JAX-RPC (Java) web service that needs to return a complex polymorphic
I am querying a database for a web service using the Jersey JAX-RS. I
Using Grails and CXF, I have published a small web service that looks like
I'm building a JAX-RS web service (Jersey) and now I'm trying to start using
I have a JAX-B java web service which I'm using to update a database.
I'm using eclipse and I have a java web service (rest jax-rs) I also
I have developed a web service using JAX-WS and in the web.xml i had
I have a WSDL file for a web service. I'm using JAX-WS/wsimport to generate

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.