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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:49:30+00:00 2026-06-13T15:49:30+00:00

I’m used to working with jax-ws where a wsdl file is generated, and a

  • 0

I’m used to working with jax-ws where a wsdl file is generated, and a client can then be generated based on this wsdl file and its xsd(s) using a maven plugin. Using this client is no hassle at at, and you don’t have to really think about what happens in the background, like marshalling, http transfer and such.

I’m currently working on a jax-rs project using jaxb to unmarshal objects. One of the methods there returns a list of strings, but it seems that jaxb does not know how to marshal this, which is kinda surprising as it does know how to marshal a list of entities (ex, customers).

Also, I have written a client for the jax-rs service on my own, handling both http responses and unmarshalling of the payload using jaxb. Marshalling and unmarshalling with jaxb is a real hassle since it cannot automatically marshall or unmarshall list of entities that is added to its context, even less lists of strings.

I would like to know if there is some neat way to get all of this for free using restful webservices? This would have to be quite lightweight, and the clients must be easy to distribute.

Thanks!
Runar

The service method that is not working using jaxrs and jaxb:

@GET
@Path("/{customerId}")
@Produces(MediaType.APPLICATION_XML)
public List<String> isCustomerLocked(@PathParam("customerId") Long customerId) {


}

Client code that attempts to marshall/unmarshall text payload. Classes added to the jaxbcontext not shown:

javax.xml.bind.Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.marshal(obj, stringwriter)

javax.xml.bind.Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.unmarshal(inputstream)
  • 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-13T15:49:31+00:00Added an answer on June 13, 2026 at 3:49 pm

    I’d use JAXB to wrap the data. For a simple List<String> this may look as overkill. But in most cases you want to un-/marshall Resource Representations, not simple objects.

    Remember: REST ist not RPC!

    If you really want tom un-/marshall List<String> write a JAX-RS Provider. But I’d prefer using JAXB.

    S.java

    @XmlRootElement
    public class S {
    
        private String s;
    
        public S() {
        }
    
        public S(String s) {
            this.s = s;
        }
    
        public String getS() {
            return s;
        }
    
        public void setS(String s) {
            this.s = s;
        }
    }
    

    Ss.java

    @XmlRootElement(name="ss-wrapper")
    public class Ss {
    
        private List<S> ss;
    
        public List<S> getSs() {
            return ss;
        }
    
        public void setSs(List<S> ss) {
            this.ss = ss;
        }
    
        public Ss(List<S> ss) {
            this.ss = ss;
        }
    
        public Ss() {
        }
    }
    

    JAX-RS class

    @Path("/strings")
    @GET
    @Produces(MediaType.APPLICATION_XML)
    public Response getListOfStrings() {
        S s1 = new S("foo");
        S s2 = new S("bar");
        List<S> strings = new ArrayList<S>();
        strings.add(s1);
        strings.add(s2);
        Ss ss = new Ss(strings);
        return Response.ok(ss).build();
    }
    

    XML

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ss-wrapper>
      <ss>
        <s>foo</s>
      </ss>
      <ss>
        <s>bar</s>
      </ss>
    </ss-wrapper>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.