Hi Nate, On Tue, Jul 12, 2011 at 9:36 PM, Nate Reed <[email protected]> wrote:
> One of the Synapse samples shows a SOAP service handling JSON requests. > > My question is what is responsible for transforming the XML payload > into JSON? This is a snippet from the definition: > <inSequence> > <log level="full"/> > <xslt key="in_transform"/> > <property name="messageType" scope="axis2" > value="text/xml"/> > </inSequence> > > Does this "messageType"= "text/xml" property result in the JSON being > transformed into XML before the XSLT transform "in_transform" is > invoked? Sorry, it's a little unclear to me what's going on here so > some clarification is appreciated. > Synapse (and Axis2) has a concept of message builders and formatters. Builders are responsible for reading the incoming byte stream and constructing a SOAP envelope out of it. The incoming stream could be XML, JSON or virtually anything. For incoming JSON messages, the JSON message builder will be called which constructs a SOAP envelope out of the JSON payload. The SOAP infoset constructed by the message builders go through the Synapse mediation engine. The mediators work with on this SOAP infoset (you can see the SOAP infoset as logged by the log mediator if you run the sample). Then at the point of departure a message formatter is invoked to convert the SOAP infoset into a byte stream which can be sent over the wire. The message formatter for an outgoing message is determined based on the value of the messageType property. The above configuration sets the property value to text/xml (which is the content type associated with the SOAP 1.1 formatter). As a result Synapse will invoke the SOAP 1.1 formatter when sending the message out which will write an XML/SOAP stream to the wire. Hope this clarifies the problem. Please holler if you have anymore questions. Thanks, Hiranya > > Thanks, > Nate > -- Hiranya Jayathilaka Senior Software Engineer; WSO2 Inc.; http://wso2.org E-mail: [email protected]; Mobile: +94 77 633 3491 Blog: http://techfeast-hiranya.blogspot.com
