Announcement Announcement Module
Collapse
No announcement yet.
AbstractMarshallingPayloadEndpoint and CastorMarshaller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AbstractMarshallingPayloadEndpoint and CastorMarshaller

    Please pardon me for these two beginner questions. I am new in the web services world and Spring, but I have read the tutorial and successfully worked on a few simple examples.

    Question # 1:
    I am now implementing a simple web service in which the endpoint extends AbstractMarshallingPayloadEndpoint and uses Castor to marshall a list of Java object to XML. I would like the web service clients to be able to get the XML file result, without having to wrap anything in a SOAP envelop. When implementing the method Object invokeInternal(Object requestObject), what type of object should I return in order to accomplish my goal? For instance, If my object is of type Car (see below). What type of OutputStream will be best? Or should I use another method?

    Object invokeInternal(Object requestObject){
    List cars = ....;
    ...
    CastorMarshaller marshaller = ...
    OutputStream outputstream = new (What type ???);
    marshaller.marshalOutputStream(list, outputstream);
    return outputstream;
    }

    Question #2:
    How can I activate the indentation of the XML resulted in the example above, so that I could better see the XML elements (not for production use)? I did not see any method of CastorMarshaller that enables me to set a castor.properties file in which I could write org.exolab.castor.indent=true

    Question #3:
    InitializingBean.class, which is referenced by AbstractMarshallingPayloadEndpoint is missing in the spring-ws jar file. Therefore, I had to include to core Spring jar. Did I download the wrong jar, or is it the way it is supposed to be?

    Once again, I am sorry for such beginner questions, but I really need some help.
    Thank you in advance.

    John

  • #2
    Originally posted by Jkelly View Post
    Question # 1:
    I am now implementing a simple web service in which the endpoint extends AbstractMarshallingPayloadEndpoint and uses Castor to marshall a list of Java object to XML. I would like the web service clients to be able to get the XML file result, without having to wrap anything in a SOAP envelop. When implementing the method Object invokeInternal(Object requestObject), what type of object should I return in order to accomplish my goal? For instance, If my object is of type Car (see below). What type of OutputStream will be best? Or should I use another method?

    Object invokeInternal(Object requestObject){
    List cars = ....;
    ...
    CastorMarshaller marshaller = ...
    OutputStream outputstream = new (What type ???);
    marshaller.marshalOutputStream(list, outputstream);
    return outputstream;
    }
    If you don't want the SOAP envelope wrapped around the marshalled object, you are doing Plain Old Xml (POX). With POX, there is no SOAP envelope, just a XML document. By defining a DomPoxMessageFactory (rather than a SaajSoapMessageFactory, or AxiomSoapMessageFactory), you enable it.


    Originally posted by Jkelly View Post
    Question #2:
    How can I activate the indentation of the XML resulted in the example above, so that I could better see the XML elements (not for production use)? I did not see any method of CastorMarshaller that enables me to set a castor.properties file in which I could write org.exolab.castor.indent=true
    It is not possible to directly set it, but you could try setting System properties. If that doesn't work, you can override the createMarshaller() or createUnmarshaller methods of the CastorMarshaller, and do your think there. Finally, you can create a JIRA issue, and I can add it to the marshaller.

    Originally posted by Jkelly View Post
    Question #3:
    InitializingBean.class, which is referenced by AbstractMarshallingPayloadEndpoint is missing in the spring-ws jar file. Therefore, I had to include to core Spring jar. Did I download the wrong jar, or is it the way it is supposed to be?
    No, that's the right way. Spring-WS builds on Spring core. We don't include it, because we don't want to force usage of a specific version of Spring. Spring-WS supports both 1.2.9 and 2.0.5.

    Comment


    • #3
      I am now implementing a simple web service in which the endpoint extends AbstractMarshallingPayloadEndpoint and uses Castor to marshall a list of Java object to XML. I would like the web service clients to be able to get the XML file result, wrapped in a SOAP envelop.
      Object invokeInternal(Object requestObject){
      List cars = ....;
      ...
      CastorMarshaller marshaller = ...
      OutputStream outputstream = new (What type ???);
      marshaller.marshalOutputStream(list, outputstream);
      return outputstream;
      }

      Comment


      • #4
        An older version of the airline sample did this. See http://springframework.svn.sourcefor...sEndpoint.java and http://springframework.svn.sourcefor...Context-ws.xml

        Comment

        Working...
        X