Works exactly as you describe.  Thank you so much.  Once again I am
impressed with Synapse.
~john

On Thu, Feb 28, 2008 at 12:18 AM, Asankha C. Perera <[EMAIL PROTECTED]> wrote:
>
>  Hi John
>
>
>  The problem is that the messagecontext only seems to want xml.
>  This is because our canonical message format is a SOAP "infoset" (note:
> this is not an XML serialization)
>
>
>  My intent is to return non-XML for the HTTP GET. setPayLoadXML for the
> script mediators requires XML doesn't it?
>  Yes, the script mediator expects XML, but the way we carry binary and text
> payloads within the SOAP infoset is by using special wrapper elements
> ns:binary and ns:text where ns refers to the
> http://ws.apache.org/commons/ns/payload namespace. Thus for your example,
> you could do the following:
>
>
> <definitions xmlns="http://ws.apache.org/ns/synapse";>
>      <sequence name="textout">
>          <drop/>
>
>      </sequence>
>      <sequence name="textin">
>          <log level="custom">
>                  <property name="request name" expression="//ns:name"
> xmlns:ns="http://org.apache.axis2/xsd"/>
>
>          </log>
>          <script language="groovy"><![CDATA[
>                    println mc.getReplyTo();
>
> mc.setTo("http://www.w3.org/2005/08/addressing/anonymous";);
>                    mc.setProperty ("RESPONSE", "true");
>                    mc.setPayloadXML('<ns:text
> xmlns:ns="http://ws.apache.org/commons/ns/payload";>hello=world</ns:text>');
>          ]]></script>
>      <property name="messageType" value="text/plain" scope="axis2-client"/>
>
>          <send/>
>      </sequence>
>      <proxy name="StockQuoteProxy" transports="http">
>          <target inSequence="textin" outSequence="textout" />
>      </proxy>
>  </definitions>
>
>  Since I assume you want the return content type to be "text/plain", I am
> setting the "messageType" property to that, and this also triggers the
> underlying Axis2 MessageFormatter (that will know how to write "text/plain"
> messages) for this content type. However, Axis2 nor Synapse dis not ship a
> message formatter for "text/plain" as Axis2 was mainly dealing with only
> SOAP, PoX/REST messages. But its easy to write one, and the code for this is
> attached to this email. Then I will edit the repository/conf/axis2.xml from
> my Synapse installation, and add this definition as:
>
>          <messageFormatter contentType="text/plain"
> class="org.apache.synapse.transport.common.PlainTextFormatter"/>
>
>  For your convenience, I am attaching a binary patch that includes the
> compiled code for the above message formatter, and you can add this to your
> lib directory if you do not want to compile the source again.
>
>  When I now do a GET request as
> "http://localhost:8080/soap/StockQuoteProxy/mediate?name=valuex";, I get the
> following reply back
>
>  [EMAIL PROTECTED]:~/java/synapse-1.1.1/bin$ telnet localhost 8080
>  Trying 127.0.0.1...
>  Connected to localhost.
>  Escape character is '^]'.
>  GET /soap/StockQuoteProxy/mediate?name=valuex HTTP/1.0
>
>  HTTP/1.0 200 OK
>  Content-Type: text/plain; charset=UTF-8
>  Date: Thu, 28 Feb 2008 08:06:35 GMT
>  Server: Synapse-HttpComponents-NIO
>  Connection: Close
>
>  hello=world
>
>  Let me know if you have any issues getting this working
>
>  asankha
>

Reply via email to