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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:37:30+00:00 2026-05-26T07:37:30+00:00

I am using spring-ws for a web service and can’t seem to figure out

  • 0

I am using spring-ws for a web service and can’t seem to figure out how to return different responses for the same initial request. Lets just say that I get a certain type of request, we will call it FindGasRequest. Now I already have the endpoint mapping set up properly so that when a FindGasRequest comes in it maps to the correct endpoint and then I perform some business logic and then return a FindGasResponse.

Here’s my question. Say I get a FindGasRequest and then in my business logic I determine that instead of returning back a FindGasResponse I want to return a ListGasStationsResponse. How would I do this if my method marked by the @PayloadRoot is expecting a FindGasResponse? I guess how can I change the payload to be something else?

I do have error checking set up so that I can throw an exception and it will return a FindGasErrorResponse through and exception handler. So my first thought was to do something similar but it seems rather hacky to throw a exception when no error occurred.

  • 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-26T07:37:31+00:00Added an answer on May 26, 2026 at 7:37 am

    sauce,

    Assuming your message schema and contract with the client allows returning a ListGasStationsResponse or FindGasResponse in response to a FindGasRequest, you’ll need to give up the annotation-based FindGas endpoint, and instead make your endpoint extend AbstractMarshallingPayloadEndpoint.

    You should then override AbstractMarshallingPayloadEndpoint.invokeInternal to return one of the two different response types as an Object. Your marshaller (this works for me with the Jaxb2Marshaller) should then automatically be able to take that Object and create the XML response for one of those types.

    Note that you may then have a mix of annotation-based and xml-configured endpoints, in which case you should follow the instructions here to set up mappings for them: http://forum.springsource.org/showthread.php?78685-Mixing-annotations-with-xml-configuration-of-endpoints.

    This approach has worked for me in Spring-WS 1.5.

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

Sidebar

Related Questions

I created a web service using Apache cfx and spring, it works, but I
I am developing a soap web service client with spring. I am using webServiceTemplate
I'm trying to make a sample SOAP web service using Spring-WS and JAXB and
I have a REST web service using spring MVC which is external-facing. I would
I'm making a Web Service using Spring MVC. Controllers are called directly by the
I am creating a web service with spring + jetty + cxf using the
I am writing a RESTful web service using JAXB and Spring MVC. In my
We have a Spring web application created using Spring MVC 3.0 In the same
I am developing a web service using Spring framework for Java and deploy on
My web service is working and I can print out the XML retrieved by

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.