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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:18:15+00:00 2026-05-19T14:18:15+00:00

I have a RESTful web service that responds to /user/{userId} with a marshalled XML

  • 0

I have a RESTful web service that responds to /user/{userId} with a marshalled XML representation of a User domain object (using JAXB). What’s an appropriate way of communicating back to the client additional details about their request, particularly if it doesn’t return the information they’re expecting? In a non-distributed Java application, you might have a catch block that deals with data access, or security exceptions. In the event that /user/{userId} doesn’t return anything (e.g. the web services persistence mechanism isn’t working, there is a security restriction, etc…) how do I include meaningful information in the response to the client?

I don’t think DTOs are what I need because I’m not looking for different representations of a domain object. Rather, I’m looking for information about what happened during the request that may have prevented it from returning the information the client expected. Would it be appropriate to enclose the domain object within some kind of ResponseObject that holds the relevant metadata? The downside to this approach is that I’d rather not have my service layer interfaces all have ResponseObject as their return type because I may very well provide a non-RESTful implementation that doesn’t have the same metadata requirements.

  • 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-19T14:18:15+00:00Added an answer on May 19, 2026 at 2:18 pm

    What’s an appropriate way of communicating back to the client additional details about their request, particularly if it doesn’t return the information they’re expecting.

    In the event that /user/{userId} doesn’t return anything (e.g. the web services persistence mechanism isn’t working, there is a security restriction, etc…) how do I include meaningful information in the response to the client?

    This is what the HTTP Status Code is used for in a RESTful service.

    To indicate that a requested userId doesn’t correspond to an actual user, you can return a 404 Not Found.

    To indicate an internal error within your application (such as not being able to connect to the database), you can return 500 Internal Server Error.

    The option you are describing – wrapping your returns in a ResponseObject which then includes the true "response status" – sounds an awful lot like SOAP.

    The beauty of REST, or at least what people claim, is that you can use the already-existing HTTP response status code to model almost all statuses of your actual response.

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

Sidebar

Related Questions

I have a RESTful WCF web service that processes huge XML files that are
I have a simple RESTful web service that print Hello World ! I'm using
Assume I have a RESTful web service, which holds information about an object that
I have a WCF web service that implements a RESTful interface. We're using the
I have a web service site that is restful enabled, so other websites/ajax script
I have created a RESTful PHP web service using Lithium which contains comments, each
I have a restful web service that generates two types of output based on
I have a RESTful web service and a rich client application using it. I
Greetings: I have put together a RESTful web service in .NET 3.5 that takes
I've implemented a Spring RESTful web service. Using Jackson JSON for Object Mapping. I

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.