You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@synapse.apache.org by J Bouck <bo...@gmail.com> on 2008/02/27 19:12:07 UTC

Possible for Synapse to return non-XML on simple HTTP GET?

Can Synapse 1.1.1 return non-XML to an HTTP GET running in standalone
(no servlet container) mode?  How?
I am seeking to reduce the complexity of the environment (by not
installing another servlet engine) and have a few "servlet" kinds of
dynamic pages that I would like to serve from a synapse installation.

~john

Re: Possible for Synapse to return non-XML on simple HTTP GET?

Posted by J Bouck <bo...@gmail.com>.
That information helps alot.  I am now able to get responses to my
HTTP GET using the url https://server/soap/StockQuoteProxy/mediate .
The problem is that the messagecontext only seems to want xml.  My
intent is to return non-XML for the HTTP GET.  setPayLoadXML for the
script mediators requires XML doesn't it?  If I set the payload to
POX, Synapse returns a string name/value pair of
test1=foo
with a Content-Type of "application/x-www-form-urlencoded; charset=UTF-8"

<definitions xmlns="http://ws.apache.org/ns/synapse">
   <sequence name="textout">
        <log level="custom">
                <property name="text" value="textout"/>
                <property name="message"
expression="get-property('MESSAGE_FORMAT')"/>
        </log>
        <send/>
    </sequence>
    <sequence name="textin">
        <log level="custom">
                <property name="text" value="textin"/>
                <property name="message"
expression="get-property('MESSAGE_FORMAT')"/>
        </log>
        <script language="groovy"><![CDATA[
                  println mc.getReplyTo();
                  mc.setTo("http://www.w3.org/2005/08/addressing/anonymous");
                  mc.setProperty ("RESPONSE", "true");
                  mc.setPayloadXML("<test><test1>foo</test1></test>");
        ]]></script>
        <send/>
    </sequence>
    <sequence name="textfault">
       <log level="full"/>
        <makefault>
                <code value="tns:Receiver"
xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
            <reason expression="get-property('ERROR_MESSAGE')"/>
        </makefault>
        <property name="RESPONSE" value="true"/>
        <send/>
    </sequence>
    <proxy name="StockQuoteProxy" transports="https">
        <target inSequence="textin" outSequence="textout"
faultSequence="textfault">
        </target>
    </proxy>
</definitions>

Any other ideas how to get non-XML in the response from an HTTP GET?
~john

On Wed, Feb 27, 2008 at 3:46 PM, Ruwan Linton <ru...@gmail.com> wrote:
> Hi John,
>
>  Yes this is acceptable, and is because there is a GET request processor
>  which filters the GET requests over the service paths in synapse and serves
>  the service information page. This is because we assumed that normally there
>  is a operation appended to the URL of the service in almost all the cases.
>
>  So you will have to try the same adding the operation to the end of the
>  service URL which is "mediate" if you do not provide a WSDL to the proxy
>  service. (we add an operation named mediate for each and every service whihc
>  does not specifies a WSDL)
>
>  So, if the service URL is http://localhost:8080/soap/xxx, then you need to
>  try http://localhost:8080/soap/xxx/mediate in-order to do a actual GET
>  request over the proxy service.
>
>  We had a discussion on adding a configuration point to change this filter
>  behaviors, and most probably will be available for the next release, so that
>  you can skip this service information filter by changing a configuration.
>
>  Thanks,
>  Ruwan
>
>
>
>  On Thu, Feb 28, 2008 at 4:06 AM, J Bouck <bo...@gmail.com> wrote:
>
>  > See the synapse.xml that I have tried, but it still does not work with
>  > HTTPS GET.  If I POST with an xml payload I see the textin sequence
>  > log messages so I know that it's working.  If I GET to
>  > /soap/StockQuoteProxy then the textin sequence log messages never
>  > appear, the faultsequence does not run, synapse hesitates for 10
>  > seconds and then returns the service definition page with the link of
>  > the wsdl (which doesn't work because there is no wsdl defined for the
>  > proxy service).  I am trying to do a simple GET on a synapse proxy.
>  > Any ideas?
>  >
>  > <definitions xmlns="http://ws.apache.org/ns/synapse">
>  >   <sequence name="textout">
>  >        <log level="custom">
>  >                <property name="text" value="textout"/>
>  >                <property name="message"
>  > expression="get-property('MESSAGE_FORMAT')"/>
>  >        </log>
>  >        <property name="RESPONSE" value="true"/>
>  >        <send/>
>  >    </sequence>
>  >    <sequence name="textin">
>  >        <log level="custom">
>  >                <property name="text" value="SYNAPSE textin error"/>
>  >                <property name="message"
>  > expression="get-property('MESSAGE_FORMAT')"/>
>  >        </log>
>  >        <drop/>
>  >    </sequence>
>  >    <sequence name="textfault">
>  >       <log level="full"/>
>  >        <makefault>
>  >                <code value="tns:Receiver"
>  > xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
>  >            <reason expression="get-property('ERROR_MESSAGE')"/>
>  >        </makefault>
>  >        <property name="RESPONSE" value="true"/>
>  >        <send/>
>  >    </sequence>
>  >    <proxy name="StockQuoteProxy" transports="https">
>  >        <target inSequence="textin" outSequence="textout"
>  > faultSequence="textfault">
>  >        </target>
>  >    </proxy>
>  > </definitions>
>  >
>  > ~john
>  >
>  >
>  > On Wed, Feb 27, 2008 at 11:04 AM, Asankha C. Perera <as...@wso2.com>
>  > wrote:
>  > > John
>  > >
>  > > > I can write an xslt that outputs text.  What would the synapse.xml
>  > >  > look like to make the response be non-xml (without soap envelope
>  > >  > wrappers, but including the appropriate http headers like mime-types
>  > >  > for the non-xml content)?
>  > >  >
>  > >  Well, I have tried this with non http/s transports such as JMS where
>  > >  this is used frequently.. The XSLT mediator will detect plain text
>  > >  output and automatically wrap it in a text element. Basically the
>  > >  message will always be a SOAP "infoset" within Synapse - a SOAP infoset
>  > >  is usually serialized into XML, but internally its just the model that
>  > >  we keep the "message" as and not in its XML representation.
>  > >
>  > >  So yes, you can continue to set transport headers on this message using
>  > >  the property mediator etc
>  > >
>  > > > I think that I would prefer to write a synapse mediator that would set
>  > >  > the servletresponse (non-xml response payload and http headers).
>  > >  > Would something like that be possible?
>  > >  >
>  > >  sure
>  > >
>  > >  asankha
>  > >
>  >
>
>
>
>  --
>  Ruwan Linton
>  http://www.wso2.org - "Oxygenating the Web Services Platform"
>

Re: Possible for Synapse to return non-XML on simple HTTP GET?

Posted by Ruwan Linton <ru...@gmail.com>.
Hi John,

Yes this is acceptable, and is because there is a GET request processor
which filters the GET requests over the service paths in synapse and serves
the service information page. This is because we assumed that normally there
is a operation appended to the URL of the service in almost all the cases.

So you will have to try the same adding the operation to the end of the
service URL which is "mediate" if you do not provide a WSDL to the proxy
service. (we add an operation named mediate for each and every service whihc
does not specifies a WSDL)

So, if the service URL is http://localhost:8080/soap/xxx, then you need to
try http://localhost:8080/soap/xxx/mediate in-order to do a actual GET
request over the proxy service.

We had a discussion on adding a configuration point to change this filter
behaviors, and most probably will be available for the next release, so that
you can skip this service information filter by changing a configuration.

Thanks,
Ruwan

On Thu, Feb 28, 2008 at 4:06 AM, J Bouck <bo...@gmail.com> wrote:

> See the synapse.xml that I have tried, but it still does not work with
> HTTPS GET.  If I POST with an xml payload I see the textin sequence
> log messages so I know that it's working.  If I GET to
> /soap/StockQuoteProxy then the textin sequence log messages never
> appear, the faultsequence does not run, synapse hesitates for 10
> seconds and then returns the service definition page with the link of
> the wsdl (which doesn't work because there is no wsdl defined for the
> proxy service).  I am trying to do a simple GET on a synapse proxy.
> Any ideas?
>
> <definitions xmlns="http://ws.apache.org/ns/synapse">
>   <sequence name="textout">
>        <log level="custom">
>                <property name="text" value="textout"/>
>                <property name="message"
> expression="get-property('MESSAGE_FORMAT')"/>
>        </log>
>        <property name="RESPONSE" value="true"/>
>        <send/>
>    </sequence>
>    <sequence name="textin">
>        <log level="custom">
>                <property name="text" value="SYNAPSE textin error"/>
>                <property name="message"
> expression="get-property('MESSAGE_FORMAT')"/>
>        </log>
>        <drop/>
>    </sequence>
>    <sequence name="textfault">
>       <log level="full"/>
>        <makefault>
>                <code value="tns:Receiver"
> xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
>            <reason expression="get-property('ERROR_MESSAGE')"/>
>        </makefault>
>        <property name="RESPONSE" value="true"/>
>        <send/>
>    </sequence>
>    <proxy name="StockQuoteProxy" transports="https">
>        <target inSequence="textin" outSequence="textout"
> faultSequence="textfault">
>        </target>
>    </proxy>
> </definitions>
>
> ~john
>
>
> On Wed, Feb 27, 2008 at 11:04 AM, Asankha C. Perera <as...@wso2.com>
> wrote:
> > John
> >
> > > I can write an xslt that outputs text.  What would the synapse.xml
> >  > look like to make the response be non-xml (without soap envelope
> >  > wrappers, but including the appropriate http headers like mime-types
> >  > for the non-xml content)?
> >  >
> >  Well, I have tried this with non http/s transports such as JMS where
> >  this is used frequently.. The XSLT mediator will detect plain text
> >  output and automatically wrap it in a text element. Basically the
> >  message will always be a SOAP "infoset" within Synapse - a SOAP infoset
> >  is usually serialized into XML, but internally its just the model that
> >  we keep the "message" as and not in its XML representation.
> >
> >  So yes, you can continue to set transport headers on this message using
> >  the property mediator etc
> >
> > > I think that I would prefer to write a synapse mediator that would set
> >  > the servletresponse (non-xml response payload and http headers).
> >  > Would something like that be possible?
> >  >
> >  sure
> >
> >  asankha
> >
>



-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"

Re: Possible for Synapse to return non-XML on simple HTTP GET?

Posted by J Bouck <bo...@gmail.com>.
See the synapse.xml that I have tried, but it still does not work with
HTTPS GET.  If I POST with an xml payload I see the textin sequence
log messages so I know that it's working.  If I GET to
/soap/StockQuoteProxy then the textin sequence log messages never
appear, the faultsequence does not run, synapse hesitates for 10
seconds and then returns the service definition page with the link of
the wsdl (which doesn't work because there is no wsdl defined for the
proxy service).  I am trying to do a simple GET on a synapse proxy.
Any ideas?

<definitions xmlns="http://ws.apache.org/ns/synapse">
   <sequence name="textout">
        <log level="custom">
                <property name="text" value="textout"/>
                <property name="message"
expression="get-property('MESSAGE_FORMAT')"/>
        </log>
        <property name="RESPONSE" value="true"/>
        <send/>
    </sequence>
    <sequence name="textin">
        <log level="custom">
                <property name="text" value="SYNAPSE textin error"/>
                <property name="message"
expression="get-property('MESSAGE_FORMAT')"/>
        </log>
        <drop/>
    </sequence>
    <sequence name="textfault">
       <log level="full"/>
        <makefault>
                <code value="tns:Receiver"
xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
            <reason expression="get-property('ERROR_MESSAGE')"/>
        </makefault>
        <property name="RESPONSE" value="true"/>
        <send/>
    </sequence>
    <proxy name="StockQuoteProxy" transports="https">
        <target inSequence="textin" outSequence="textout"
faultSequence="textfault">
        </target>
    </proxy>
</definitions>

~john


On Wed, Feb 27, 2008 at 11:04 AM, Asankha C. Perera <as...@wso2.com> wrote:
> John
>
> > I can write an xslt that outputs text.  What would the synapse.xml
>  > look like to make the response be non-xml (without soap envelope
>  > wrappers, but including the appropriate http headers like mime-types
>  > for the non-xml content)?
>  >
>  Well, I have tried this with non http/s transports such as JMS where
>  this is used frequently.. The XSLT mediator will detect plain text
>  output and automatically wrap it in a text element. Basically the
>  message will always be a SOAP "infoset" within Synapse - a SOAP infoset
>  is usually serialized into XML, but internally its just the model that
>  we keep the "message" as and not in its XML representation.
>
>  So yes, you can continue to set transport headers on this message using
>  the property mediator etc
>
> > I think that I would prefer to write a synapse mediator that would set
>  > the servletresponse (non-xml response payload and http headers).
>  > Would something like that be possible?
>  >
>  sure
>
>  asankha
>

Re: Possible for Synapse to return non-XML on simple HTTP GET?

Posted by "Asankha C. Perera" <as...@wso2.com>.
John
> I can write an xslt that outputs text.  What would the synapse.xml
> look like to make the response be non-xml (without soap envelope
> wrappers, but including the appropriate http headers like mime-types
> for the non-xml content)?
>   
Well, I have tried this with non http/s transports such as JMS where 
this is used frequently.. The XSLT mediator will detect plain text 
output and automatically wrap it in a text element. Basically the 
message will always be a SOAP "infoset" within Synapse - a SOAP infoset 
is usually serialized into XML, but internally its just the model that 
we keep the "message" as and not in its XML representation.

So yes, you can continue to set transport headers on this message using 
the property mediator etc
> I think that I would prefer to write a synapse mediator that would set
> the servletresponse (non-xml response payload and http headers).
> Would something like that be possible?
>   
sure

asankha

Re: Possible for Synapse to return non-XML on simple HTTP GET?

Posted by J Bouck <bo...@gmail.com>.
I can write an xslt that outputs text.  What would the synapse.xml
look like to make the response be non-xml (without soap envelope
wrappers, but including the appropriate http headers like mime-types
for the non-xml content)?

I think that I would prefer to write a synapse mediator that would set
the servletresponse (non-xml response payload and http headers).
Would something like that be possible?

~john

On Wed, Feb 27, 2008 at 10:26 AM, Asankha C. Perera <as...@wso2.com> wrote:
> John
>
> > Can Synapse 1.1.1 return non-XML to an HTTP GET running in standalone
>  > (no servlet container) mode?  How?
>  >
>  Yes, this should be possible - although I haven't tested this yet. An
>  easy way to do this would be to use an XSLT that outputs plan text. This
>  would be wrapped in a "text" element in the SOAP infoset payload/message
>  we would pass (i.e. if you log this "text" message you would see this)
>  and on the send, the payload should just go over HTTP
>
> > I am seeking to reduce the complexity of the environment (by not
>  > installing another servlet engine) and have a few "servlet" kinds of
>  > dynamic pages that I would like to serve from a synapse installation.
>  >
>  Let me know if you encounter any issues with this, and we can help you
>  achieve your desired objective
>
>  asankha
>

Re: Possible for Synapse to return non-XML on simple HTTP GET?

Posted by "Asankha C. Perera" <as...@wso2.com>.
John
> Can Synapse 1.1.1 return non-XML to an HTTP GET running in standalone
> (no servlet container) mode?  How?
>   
Yes, this should be possible - although I haven't tested this yet. An 
easy way to do this would be to use an XSLT that outputs plan text. This 
would be wrapped in a "text" element in the SOAP infoset payload/message 
we would pass (i.e. if you log this "text" message you would see this) 
and on the send, the payload should just go over HTTP
> I am seeking to reduce the complexity of the environment (by not
> installing another servlet engine) and have a few "servlet" kinds of
> dynamic pages that I would like to serve from a synapse installation.
>   
Let me know if you encounter any issues with this, and we can help you 
achieve your desired objective

asankha