Results 1 to 2 of 2

Thread: Using AbstractMarshallingPayloadEndpoint

  1. #1
    Join Date
    Aug 2004
    Location
    Dallas
    Posts
    10

    Default Using AbstractMarshallingPayloadEndpoint

    I am just getting started with Spring-WS. My ititial EndPoint implementation subclassed AbstractDomPayloadEndpoint and manually handled the Marshalling/Unmarshalling. I now want to try it by subclassing AbstractMarshallingPayloadEndpoint and use Castor as my XML marshalling framework.

    My first pass was to simply declare a CastorMarshaller bean with no mapping file and use this my end point's marshaller and unmarshaller. I did not expect this to work - I just wanted to see what happened. Naturally, I got an exception:

    org.springframework.oxm.castor.CastorUnmarshalling FailureException: Castor unmarshalling exception: The class for the root element 'GetCalendarDayRequest' could not be found.; nested exception is The class for the root element 'GetCalendarDayRequest' could not be found.

    Fine - I have not mapped this class yet, so Castor does not no how to handle this. But this brings up a question I have regarding the typical Spring-WS method for mapping messages. In my case, my schema (simple at this point) looks like this:

    <element name="GetCalendarDayRequest">
    <complexType>
    <sequence>
    <element name="Date" type="date" />
    </sequence>
    </complexType>
    </element>

    <element name="GetCalendarDayResponse">
    <complexType>
    <sequence>
    <element name="CalendarDay" type="tns:CalendarDay"/>
    </sequence>
    </complexType>
    </element>

    <complexType name="CalendarDay">
    <sequence>
    <element name="Date" type="date"/>
    <element name="Type" type="string"/>
    <element name="WorkDay" type="boolean"/>
    <element name="LastWorkDayOfTheMonth" type="boolean"/>
    </sequence>
    </complexType>

    As you can see, I have a declaration for my request, response and a complex type with my response. So the top level element of my incoming request message is a <GetCalendarDayRequest>. However, I don't want to map *this* to an object, only the contents. The same goes for the response. In other words, These elements exist only to wrap the contents of the SOAP messages. I would prefer to not inroduce these as real objects.

    In the sample Castor mappings that come with Spring-WS, there are mapping for the flights and flight elements, but none for the GetFlightsRequest and GetFlightsResponse elements that are in the airline.xsd schema file in the Airline example.

    So, to sum up this rambling, is it necessary to map request and response "wrapper" elements, or is there a way to bypass these elements and go straight to the sub-elements, were the domain-specific elements are located.

    Thanks.

    Ryan

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Quote Originally Posted by breidenr
    As you can see, I have a declaration for my request, response and a complex type with my response. So the top level element of my incoming request message is a <GetCalendarDayRequest>. However, I don't want to map *this* to an object, only the contents. The same goes for the response. In other words, These elements exist only to wrap the contents of the SOAP messages. I would prefer to not inroduce these as real objects.
    The contents of a SOAP body consists of a single element. This element is what is unmarshalled to an object. So, in your example, instead of wrapping CalendarDay in a seperate response object, you could make GetCalendarDayResponse have type Calenday itself, like so:

    Code:
    <element name="GetCalendarDayResponse" type="tns:CalendarDay"/>
    Quote Originally Posted by breidenr
    In the sample Castor mappings that come with Spring-WS, there are mapping for the flights and flight elements, but none for the GetFlightsRequest and GetFlightsResponse elements that are in the airline.xsd schema file in the Airline example.
    I think you are referring to the O/X mapping unit tests, because there is no usage of Castor in the Airline example. These tests do not reflect a complete Web service schema, just some tests elements to test Castor and other OXM technologies.

    Quote Originally Posted by breidenr
    So, to sum up this rambling, is it necessary to map request and response "wrapper" elements, or is there a way to bypass these elements and go straight to the sub-elements, were the domain-specific elements are located.
    The only thing that is necessary is that you map the single payload element to an object. What is in that element is totally up to you.

    Cheers,
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •