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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:17:16+00:00 2026-06-08T12:17:16+00:00

I am successfully created restful web service and deploy it in Apache Tomcat 7.0.

  • 0

I am successfully created restful web service and deploy it in Apache Tomcat 7.0. After successful deployment I start my server. By using the below command i invoke the web service.

WebResource resource = client.resource("http://localhost:8080/rest/samp/create"); 

My web method is

@POST
@Path("/create")
@Produces(MediaType.TEXT_XML)
@Consumes(MediaType.TEXT_XML)
public final String sample(final String xmlMessage) {

    return "<xml version=1.0><welcome>"+xmlmessage+"</welcome>";    
}

Here I am passing XML content as argument and get the XML content as response.

Now what I need is how to pass the XML content to the web method.

  • 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-08T12:17:17+00:00Added an answer on June 8, 2026 at 12:17 pm

    I’m guessing that the library in use here is Jersey.

    You have to use a builder to set the appropriate HTTP headers, method and entity body.

    WebResource resource = client.resource("http://localhost:8080/rest/samp/create");
    String request = "<your_xml>...</your_xml>";
    String response = resource.accept(
         MediaType.TEXT_XML).
         header("X-FOO", "BAR"). //this line is not necessary, just an example
         type(MediaType.TEXT_XML).
         post(String.class, request);
    

    But I recommend using JAXB instead. Creating XML as plain strings is just crude and unnecessarily annoying. It doesn’t show in such a simple example (grabbing a whole XML and wrapping it with another tag) but it will soon enough.

    This tutorial should get you started.

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

Sidebar

Related Questions

I successfully created database on my local server using Code First, migrated it to
I successfully created my first Entity Framework Code first project using SQL Server CE.
I have succesfully implemented a RESTful Web Service using the .NET 4.0 framework with
As I understand it, using a hypertext-driven RESTful Web service, a client is not
I successfully created my war file using warble. I am trying to deploy my
I have successfully created a Python Windows service using pywin32. In testing my application
I have successfully created Web Services from MySQL Database using Netbeans tutorial . However,
I successfully created a project using Wicket quickstart and turned it into an Eclipse
I've successfully created a WCF service that works how I want it to. The
I successfully created an RMI service and client. I can call methods and so

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.