Results 1 to 9 of 9

Thread: PayloadRootQNameEndpointMapping question

  1. #1
    Join Date
    Dec 2005
    Posts
    929

    Default PayloadRootQNameEndpointMapping question

    Hi,
    I'm developing a TCP sockets application where just an XML payload is sent back and forth through a TCP pipe. The application uses MINA to send and receive the messages. I want to know if I can use the spring-ws endpoint mappings to route the incoming message based on the root QName to some handler for JiBX to unmarshall the xml? As I mentioned before the message is just plain old XML and not wrapped in a SOAP message.
    Thanks
    Alan

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

    Default

    Raw TCP/IP support is planned for 1.1. It's actually in the sandbox right now, and it works (for me). So you could try, and give me some feedback on it. No documentation yet, but there are a couple of test cases which show how it's supposed to work.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3
    Join Date
    Dec 2005
    Posts
    929

    Default

    I've been browsing the spring CVS repository but haven't found the sandbox code. Would you please post the URL to the code?
    Thanks
    Alan

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

    Default

    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  5. #5
    Join Date
    Dec 2005
    Posts
    929

    Default

    Arjen,
    I had a look at these classes but I don't believe it's what I need.
    Our requirements now are more clear. I need to provide protocol support for clients that connect via:
    1) A web service, with a SOAP-wrapped XML message body. This will be straightforward, as I will write endpoints and congifure endpoint mappings with spring-ws.
    2) TCP socket support with Apache MINA accepting just plain old XML messages.

    I would like to be able to switch to either with a Sprng configuration setting, that is, I would like if possible when my MINA IoAcceptor receives the XML message to be able to use the same (spring-ws) endpoints. Is this possible?
    Thanks
    Alan

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

    Default

    Well, you could write your own transport. The HTTP, JMS, TCP, and Email implementations should give enough examples.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  7. #7
    Join Date
    Dec 2005
    Posts
    929

    Default

    Actually I ddn't have to write a transport, but still have a problem. I injected a MessageDispatcher into my Mina IoHandler and in the (overridden) messageReceived method I added this code:

    Code:
    WebServiceMessageFactory webServiceMessageFactory = new PoxMessageFactory();
    PoxMessage poxMessage = new PoxMessageImpl(requestPayload);
    MessageContext messageContext = new DefaultMessageContext(poxMessage, webServiceMessageFactory);
    messageDispatcher.receive(messageContext);
    where the PoxMessageImpl is a class I wrote that implements PoxMessage that takes in an xml string:

    Code:
    public class PoxMessageImpl implements PoxMessage {
    	private String payload;
    
    	public PoxMessageImpl(String payload) {
    		Validate.notNull(payload, "Payload must not be null");
    		this.payload = payload;
    	}
    
    	public Result getPayloadResult() {
    		StringWriter writer = new StringWriter();
    		writer.write(payload);
    		return new StreamResult(writer);
    	}
    
    	public Source getPayloadSource() {
    		StringReader reader = new StringReader(payload);
    		return new StreamSource(reader);
    	}
    
    	public void writeTo(OutputStream outputStream) throws IOException {
    		StringReader reader = new StringReader(payload);
    		IOUtils.copy(reader, outputStream);
    	}
    }
    The marshalResponse(responseObject, response) method in AbstractMarshallingPayloadEndpoint (my endpoint extends this class) eventually calls marshaller.marshal(graph, message.getPayloadResult()) in Marshallingutils, however, my PoxMessageImpl getPayloadResult() returns an empty Result, as I not sure what I should be returning here. Though I can see the response object in the "graph" while debugging, currently the payload is coming back empty after this. I'm using the JibxMarshaller.

    I can also see the marshalled reesponse xml from the marshalWriter(graph, streamResult.getWriter()); method in the org.springframework.oxm.AbstractMarshaller, but after it returns to the marshal method in MarshallingUtils, the payload of the response message still empty. What's missing here?

    Any ideas?

    Thanks
    Last edited by Alan Stewart; Sep 23rd, 2007 at 11:59 PM.

  8. #8
    Join Date
    Dec 2005
    Posts
    929

    Default

    I abandoned my own PoxMessageImpl class and used the DomPoxMessage instead. The MessageContext's response is now getting populated with the marshalled xml and all is working. I'd still like to know why my own implementation is not working.

    Also, I read somewhere that using dom documents is not suppoprted by the JibxMarshaller. Is this so?
    Last edited by Alan Stewart; Sep 24th, 2007 at 06:35 AM.

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

    Default

    Quote Originally Posted by aks View Post
    I abondoned my own PoxMessageImpl class and used the DomPoxMessage instead. The MessageContext's response is now getting populated with the marshalled xml and all is working. I'd still like to know why my own implementation is not working.
    The problem lies with the getPayloadResult(). Whenever something is written to this Result, the writer contents is not synchronized with the String. You could fix this by creating your own Writer, which syncs the String whenever close() is called. Or, you use the DomPoxMessage, like you do now .

    Quote Originally Posted by aks View Post
    Also, I read somewhere that using dom documents is not suppoprted by the JibxMarshaller. Is this so?
    That used to be true for earlier versions of Spring-WS, but is not true anymore.
    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
  •