You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@synapse.apache.org by Manuel Corrales <mc...@starmountsystems.com> on 2012/06/26 20:26:10 UTC

Synapse as REST facade

Hello, I have this scenario and can't figure out how to make it work with
synapse:
I would like to make synapse lo "listen" to a simple REST url like this:

"hostname/assest/1/15" where a and 15 are ids. (Like for instance get
assest 15 of user 1)

then, I have another external service with a longer url that performs the
actual fetching of the asset. So the idea would be that the synapse REST
get would call this external service and send the binary asset (an image)
to the caller.


So basically it would be like this:


Enter a url in a browser: localhost/asset/1/15
synapse listen this url and calls "
http://externalservice/getAsset/1/15/content" and return the binary
response of this service to the original caller.


Any hints? I have tried with an api and also with a proxy, but there seems
that I can't make it work:



<proxy name="asset" transports="http">
    <target>
        <endpoint>
            <address uri="
http://localhost:8085/digitalassets-app/content/1-RetailStore/15-SKU/asset/content"
format="get"/>
            <log level="full"/>
        </endpoint>
        <outSequence>
            <log level="full"/>
        </outSequence>
    </target>
</proxy>

<api name="DigitalAssets" context="/assets">
    <resource uri-template="/{store}/{sku}" methods="GET">
        <inSequence>
            <log level="full"/>
            <send>
                <endpoint >
                    <address uri="http://www.google.com" format="get"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <log level="full"/>
        </outSequence>
    </resource>
</api>


Thanks in advance!
Regards,
Manuel

-- 
Disclaimer: The information contained in this communication is confidential 
and only for the use of the intended addressee(s).  If you have received 
this communication in error, any disclosure or use of such information is 
strictly prohibited.  Please notify the sender immediately and destroy all 
copies.  Thank you.


Re: Synapse as REST facade

Posted by Hiranya Jayathilaka <hi...@gmail.com>.
On Wed, Jun 27, 2012 at 4:59 PM, Manuel Corrales <
mcorrales@starmountsystems.com> wrote:

> Thanks! And what about sending back the raw response? As the call give an
> image and I need synapse not to process but to send the response untouched.
>

Synapse doesn't have a built-in way of doing this. But there are several
extensions available which supports this. You can check
http://wso2.org/project/esb/java/4.0.3/docs/message_relay.html to learn
about one such extension. It was developed for WSO2 ESB, but also works on
Synapse.

Thanks,
Hiranya


>
> Thanks in advance.
> El 27/06/2012 02:13, "Hiranya Jayathilaka" <hi...@gmail.com>
> escribió:
>
> > You can use an API to receive the GET request and then do a URL rewrite
> > using the URL rewrite mediator. Refer samples 450, 451 and 452 to learn
> how
> > to use the rewrite mediator. The outline of the API configuration you
> have
> > given above looks correct. You should be able to modify it by adding the
> > rewrite mediator and get your scenario to work.
> >
> > Thanks,
> > Hiranya
> >
> > On Wed, Jun 27, 2012 at 1:39 AM, Manuel Corrales <
> > mcorrales@starmountsystems.com> wrote:
> >
> > > Ok, let me simplify. I have an image server and want to put synapse
> > between
> > > the image server and the client. The images server images are accessed
> > > using REST urls and I would like the synapse service facing the clien
> to
> > be
> > > REST too.
> > >
> > > Thanks in advance!
> > > Regards,
> > > Manuel
> > >
> > > On Tue, Jun 26, 2012 at 3:26 PM, Manuel Corrales <
> > > mcorrales@starmountsystems.com> wrote:
> > >
> > > > Hello, I have this scenario and can't figure out how to make it work
> > with
> > > > synapse:
> > > > I would like to make synapse lo "listen" to a simple REST url like
> > this:
> > > >
> > > > "hostname/assest/1/15" where a and 15 are ids. (Like for instance get
> > > > assest 15 of user 1)
> > > >
> > > > then, I have another external service with a longer url that performs
> > the
> > > > actual fetching of the asset. So the idea would be that the synapse
> > REST
> > > > get would call this external service and send the binary asset (an
> > image)
> > > > to the caller.
> > > >
> > > >
> > > > So basically it would be like this:
> > > >
> > > >
> > > > Enter a url in a browser: localhost/asset/1/15
> > > > synapse listen this url and calls "
> > > > http://externalservice/getAsset/1/15/content" and return the binary
> > > > response of this service to the original caller.
> > > >
> > > >
> > > > Any hints? I have tried with an api and also with a proxy, but there
> > > seems
> > > > that I can't make it work:
> > > >
> > > >
> > > >
> > > > <proxy name="asset" transports="http">
> > > >     <target>
> > > >         <endpoint>
> > > >             <address uri="
> > > >
> > >
> >
> http://localhost:8085/digitalassets-app/content/1-RetailStore/15-SKU/asset/content
> > > "
> > > > format="get"/>
> > > >             <log level="full"/>
> > > >         </endpoint>
> > > >         <outSequence>
> > > >             <log level="full"/>
> > > >         </outSequence>
> > > >     </target>
> > > > </proxy>
> > > >
> > > > <api name="DigitalAssets" context="/assets">
> > > >     <resource uri-template="/{store}/{sku}" methods="GET">
> > > >         <inSequence>
> > > >             <log level="full"/>
> > > >             <send>
> > > >                 <endpoint >
> > > >                     <address uri="http://www.google.com"
> > format="get"/>
> > > >                 </endpoint>
> > > >             </send>
> > > >         </inSequence>
> > > >         <outSequence>
> > > >             <log level="full"/>
> > > >         </outSequence>
> > > >     </resource>
> > > > </api>
> > > >
> > > >
> > > > Thanks in advance!
> > > > Regards,
> > > > Manuel
> > > >
> > > >
> > > >
> > >
> > > --
> > > Disclaimer: The information contained in this communication is
> > confidential
> > > and only for the use of the intended addressee(s).  If you have
> received
> > > this communication in error, any disclosure or use of such information
> is
> > > strictly prohibited.  Please notify the sender immediately and destroy
> > all
> > > copies.  Thank you.
> > >
> > >
> >
> >
> > --
> > Hiranya Jayathilaka
> > Associate Technical Lead;
> > WSO2 Inc.;  http://wso2.org
> > E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
> > Blog: http://techfeast-hiranya.blogspot.com
> >
>
> --
> Disclaimer: The information contained in this communication is confidential
> and only for the use of the intended addressee(s).  If you have received
> this communication in error, any disclosure or use of such information is
> strictly prohibited.  Please notify the sender immediately and destroy all
> copies.  Thank you.
>
>


-- 
Hiranya Jayathilaka
Associate Technical Lead;
WSO2 Inc.;  http://wso2.org
E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com

Re: Synapse as REST facade

Posted by Manuel Corrales <mc...@starmountsystems.com>.
Thanks! And what about sending back the raw response? As the call give an
image and I need synapse not to process but to send the response untouched.

Thanks in advance.
El 27/06/2012 02:13, "Hiranya Jayathilaka" <hi...@gmail.com> escribió:

> You can use an API to receive the GET request and then do a URL rewrite
> using the URL rewrite mediator. Refer samples 450, 451 and 452 to learn how
> to use the rewrite mediator. The outline of the API configuration you have
> given above looks correct. You should be able to modify it by adding the
> rewrite mediator and get your scenario to work.
>
> Thanks,
> Hiranya
>
> On Wed, Jun 27, 2012 at 1:39 AM, Manuel Corrales <
> mcorrales@starmountsystems.com> wrote:
>
> > Ok, let me simplify. I have an image server and want to put synapse
> between
> > the image server and the client. The images server images are accessed
> > using REST urls and I would like the synapse service facing the clien to
> be
> > REST too.
> >
> > Thanks in advance!
> > Regards,
> > Manuel
> >
> > On Tue, Jun 26, 2012 at 3:26 PM, Manuel Corrales <
> > mcorrales@starmountsystems.com> wrote:
> >
> > > Hello, I have this scenario and can't figure out how to make it work
> with
> > > synapse:
> > > I would like to make synapse lo "listen" to a simple REST url like
> this:
> > >
> > > "hostname/assest/1/15" where a and 15 are ids. (Like for instance get
> > > assest 15 of user 1)
> > >
> > > then, I have another external service with a longer url that performs
> the
> > > actual fetching of the asset. So the idea would be that the synapse
> REST
> > > get would call this external service and send the binary asset (an
> image)
> > > to the caller.
> > >
> > >
> > > So basically it would be like this:
> > >
> > >
> > > Enter a url in a browser: localhost/asset/1/15
> > > synapse listen this url and calls "
> > > http://externalservice/getAsset/1/15/content" and return the binary
> > > response of this service to the original caller.
> > >
> > >
> > > Any hints? I have tried with an api and also with a proxy, but there
> > seems
> > > that I can't make it work:
> > >
> > >
> > >
> > > <proxy name="asset" transports="http">
> > >     <target>
> > >         <endpoint>
> > >             <address uri="
> > >
> >
> http://localhost:8085/digitalassets-app/content/1-RetailStore/15-SKU/asset/content
> > "
> > > format="get"/>
> > >             <log level="full"/>
> > >         </endpoint>
> > >         <outSequence>
> > >             <log level="full"/>
> > >         </outSequence>
> > >     </target>
> > > </proxy>
> > >
> > > <api name="DigitalAssets" context="/assets">
> > >     <resource uri-template="/{store}/{sku}" methods="GET">
> > >         <inSequence>
> > >             <log level="full"/>
> > >             <send>
> > >                 <endpoint >
> > >                     <address uri="http://www.google.com"
> format="get"/>
> > >                 </endpoint>
> > >             </send>
> > >         </inSequence>
> > >         <outSequence>
> > >             <log level="full"/>
> > >         </outSequence>
> > >     </resource>
> > > </api>
> > >
> > >
> > > Thanks in advance!
> > > Regards,
> > > Manuel
> > >
> > >
> > >
> >
> > --
> > Disclaimer: The information contained in this communication is
> confidential
> > and only for the use of the intended addressee(s).  If you have received
> > this communication in error, any disclosure or use of such information is
> > strictly prohibited.  Please notify the sender immediately and destroy
> all
> > copies.  Thank you.
> >
> >
>
>
> --
> Hiranya Jayathilaka
> Associate Technical Lead;
> WSO2 Inc.;  http://wso2.org
> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
> Blog: http://techfeast-hiranya.blogspot.com
>

-- 
Disclaimer: The information contained in this communication is confidential 
and only for the use of the intended addressee(s).  If you have received 
this communication in error, any disclosure or use of such information is 
strictly prohibited.  Please notify the sender immediately and destroy all 
copies.  Thank you.


Re: Synapse as REST facade

Posted by Hiranya Jayathilaka <hi...@gmail.com>.
You can use an API to receive the GET request and then do a URL rewrite
using the URL rewrite mediator. Refer samples 450, 451 and 452 to learn how
to use the rewrite mediator. The outline of the API configuration you have
given above looks correct. You should be able to modify it by adding the
rewrite mediator and get your scenario to work.

Thanks,
Hiranya

On Wed, Jun 27, 2012 at 1:39 AM, Manuel Corrales <
mcorrales@starmountsystems.com> wrote:

> Ok, let me simplify. I have an image server and want to put synapse between
> the image server and the client. The images server images are accessed
> using REST urls and I would like the synapse service facing the clien to be
> REST too.
>
> Thanks in advance!
> Regards,
> Manuel
>
> On Tue, Jun 26, 2012 at 3:26 PM, Manuel Corrales <
> mcorrales@starmountsystems.com> wrote:
>
> > Hello, I have this scenario and can't figure out how to make it work with
> > synapse:
> > I would like to make synapse lo "listen" to a simple REST url like this:
> >
> > "hostname/assest/1/15" where a and 15 are ids. (Like for instance get
> > assest 15 of user 1)
> >
> > then, I have another external service with a longer url that performs the
> > actual fetching of the asset. So the idea would be that the synapse REST
> > get would call this external service and send the binary asset (an image)
> > to the caller.
> >
> >
> > So basically it would be like this:
> >
> >
> > Enter a url in a browser: localhost/asset/1/15
> > synapse listen this url and calls "
> > http://externalservice/getAsset/1/15/content" and return the binary
> > response of this service to the original caller.
> >
> >
> > Any hints? I have tried with an api and also with a proxy, but there
> seems
> > that I can't make it work:
> >
> >
> >
> > <proxy name="asset" transports="http">
> >     <target>
> >         <endpoint>
> >             <address uri="
> >
> http://localhost:8085/digitalassets-app/content/1-RetailStore/15-SKU/asset/content
> "
> > format="get"/>
> >             <log level="full"/>
> >         </endpoint>
> >         <outSequence>
> >             <log level="full"/>
> >         </outSequence>
> >     </target>
> > </proxy>
> >
> > <api name="DigitalAssets" context="/assets">
> >     <resource uri-template="/{store}/{sku}" methods="GET">
> >         <inSequence>
> >             <log level="full"/>
> >             <send>
> >                 <endpoint >
> >                     <address uri="http://www.google.com" format="get"/>
> >                 </endpoint>
> >             </send>
> >         </inSequence>
> >         <outSequence>
> >             <log level="full"/>
> >         </outSequence>
> >     </resource>
> > </api>
> >
> >
> > Thanks in advance!
> > Regards,
> > Manuel
> >
> >
> >
>
> --
> Disclaimer: The information contained in this communication is confidential
> and only for the use of the intended addressee(s).  If you have received
> this communication in error, any disclosure or use of such information is
> strictly prohibited.  Please notify the sender immediately and destroy all
> copies.  Thank you.
>
>


-- 
Hiranya Jayathilaka
Associate Technical Lead;
WSO2 Inc.;  http://wso2.org
E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com

Re: Synapse as REST facade

Posted by Manuel Corrales <mc...@starmountsystems.com>.
Ok, let me simplify. I have an image server and want to put synapse between
the image server and the client. The images server images are accessed
using REST urls and I would like the synapse service facing the clien to be
REST too.

Thanks in advance!
Regards,
Manuel

On Tue, Jun 26, 2012 at 3:26 PM, Manuel Corrales <
mcorrales@starmountsystems.com> wrote:

> Hello, I have this scenario and can't figure out how to make it work with
> synapse:
> I would like to make synapse lo "listen" to a simple REST url like this:
>
> "hostname/assest/1/15" where a and 15 are ids. (Like for instance get
> assest 15 of user 1)
>
> then, I have another external service with a longer url that performs the
> actual fetching of the asset. So the idea would be that the synapse REST
> get would call this external service and send the binary asset (an image)
> to the caller.
>
>
> So basically it would be like this:
>
>
> Enter a url in a browser: localhost/asset/1/15
> synapse listen this url and calls "
> http://externalservice/getAsset/1/15/content" and return the binary
> response of this service to the original caller.
>
>
> Any hints? I have tried with an api and also with a proxy, but there seems
> that I can't make it work:
>
>
>
> <proxy name="asset" transports="http">
>     <target>
>         <endpoint>
>             <address uri="
> http://localhost:8085/digitalassets-app/content/1-RetailStore/15-SKU/asset/content"
> format="get"/>
>             <log level="full"/>
>         </endpoint>
>         <outSequence>
>             <log level="full"/>
>         </outSequence>
>     </target>
> </proxy>
>
> <api name="DigitalAssets" context="/assets">
>     <resource uri-template="/{store}/{sku}" methods="GET">
>         <inSequence>
>             <log level="full"/>
>             <send>
>                 <endpoint >
>                     <address uri="http://www.google.com" format="get"/>
>                 </endpoint>
>             </send>
>         </inSequence>
>         <outSequence>
>             <log level="full"/>
>         </outSequence>
>     </resource>
> </api>
>
>
> Thanks in advance!
> Regards,
> Manuel
>
>
>

-- 
Disclaimer: The information contained in this communication is confidential 
and only for the use of the intended addressee(s).  If you have received 
this communication in error, any disclosure or use of such information is 
strictly prohibited.  Please notify the sender immediately and destroy all 
copies.  Thank you.