Hi,

- The first cut of the HTTP Endpoints for outbound REST integration (I have
attached the diff and required esb config). Basically, this feature allows
us to create a new endpoint type 'http' to facilitate outbound REST calls.
The outbound uri is dynamically generated with the use of URI Templates and
required http method can be selected.

- Since the WSO2 URI-template doesn't support expanding, *
https://github.com/damnhandy/Handy-URI-Templates* was used.
- Also, this endpoint type allows us to dynamically construct the endpoint
uri for SOAP services as well (i.e by method set to POST).

*Sample Scenario:*

The scenario is to send a outbound http call to an external RESTful
service.
SOAP () - > REST ()

*GET*
http://localhost:8080/PizzaShopServlet/restapi/PizzaWS/menu?category=pizza&type=pan

*POST*
http://localhost:8080/PizzaShopServlet/restapi/PizzaWS

So we can have endpoint uri template as follows :
*http://localhost:8080/{uri.var.servicepath}/restapi/{uri.var.servicename
}/menu?category={uri.var.}&type={uri.var.pizzaType}*

eg:
<endpoint xmlns="http://ws.apache.org/ns/synapse"; name="TestEP">
 <http uri-template="
http://localhost:8080/{uri.var.servicepath}/restapi/{uri.var.servicename}/menu?category={uri.var.category}&amp;type={uri.var.pizzaType}<http://localhost:8080/%7Buri.var.servicepath%7D/restapi/%7Buri.var.servicename%7D/menu?category=%7Buri.var.category%7D&type=%7Buri.var.pizzaType%7D>
"
          method="GET"></http>
</endpoint>

The properties defined in the inSeq will get dynamically expanded during
the outbound call.
 <inSequence>
            <property name="uri.var.servicepath" value="PizzaShopServlet"/>
            <property name="uri.var.servicename" value="PizzaWS"/>
            <property name="uri.var.category" value="pizza"/>
            <property name="uri.var.pizzaType" value="pan"/>
            <send>
                <endpoint key="TestEP"/>
            </send>
</inSequence>



Remaining stuff :
- Payload Factory for other formats
- HTTP Header mediator
- HTTP EP UI




---------- Forwarded message ----------
From: Kasun Indrasiri <[email protected]>
Date: Thu, Nov 8, 2012 at 11:28 AM
Subject: [Architecture]Outbound HTTP Calls in the ESB
To: architecture <[email protected]>


We had a discussion on the $subject.

*Attendees: Kasun, Miyuru, Paul, Sanjiva, Shankar.
Date: Wed Nov 7 2012

<endpoint name=”...”>

<!-- template below can refer to any Synapse property - evaluation is
deferred until runtime -->

<http uri-template=”http[s]://host:port/{x}/{foo}/{extra-stuff}”
[method=”string or {property}”]

                       [statistics="enable|disable"]
[trace="enable|disable"]>

   <header name=”..” (value=”string or {property}” |
expression=”xpath-expression”)/>*

   <timeout>
       <duration>timeout duration in milliseconds</duration>
       <action>discard|fault</action>
   </timeout>?

   <markForSuspension>
       [<errorCodes>xxx,yyy</errorCodes>]
       <retriesBeforeSuspension>m</retriesBeforeSuspension>
       <retryDelay>d</retryDelay>
   </markForSuspension>

   <suspendOnFailure>
       [<errorCodes>xxx,yyy</errorCodes>]
       <initialDuration>n</initialDuration>
       <progressionFactor>r</progressionFactor>
       <maximumDuration>l</maximumDuration>
   </suspendOnFailure>
</http>
</endpoint>

<api ..>
<resource template=/uri/{user}..>
   <payload-factory [media-type=”application/json”]>
        ONE OF:
      <json>{“a” : {{uri.var.user}}, “b” : “$1”}</json>
       <text>Hello there Mr. $1</text>
      <xhtml><![CDATA …]></xhtml>
        <resource (source=”uri” | key=”reg-key”)/>
       <formatxml>
           <a>$1</a>
          <b>$2</b>
        </formatxml>
        <class name=”FQDN”/>

        [<arg value/expressionxpath/jsonproperty=”$ctx:uri.var.user”/>*]

 </payload-factory>
    <http-header name=”string or {property}”
                         (value=”string or {property}” |
expression=”xpath-expression”)
                        [action=”add|remove”]/>
    <send endpoint=”http-endpoint-x”/>
 </resource>
</api>

ACTIONS:

   - Create new http-endpoint endpoint
   - Create new mediator http-header
   - Improve <payoad-factory> to be more generic as above
   - Samples!



Check out https://github.com/damnhandy/Handy-URI-Templates as possible tool
to create URIs with URI templates. (Our one is for parsing URIs using
templates.)

Samples:

HTTP GET to POST
Simple transform of XML to JSON using a Payload factory
SOAP to REST example
JSON to XML
 *

-- 
Kasun Indrasiri
Associate Technical Lead
WSO2, Inc.; http://wso2.com
lean.enterprise.middleware

cell: +94 71 536 4128
Blog : http://kasunpanorama.blogspot.com/



-- 
Kasun Indrasiri
Associate Technical Lead
WSO2, Inc.; http://wso2.com
lean.enterprise.middleware

cell: +94 71 536 4128
Blog : http://kasunpanorama.blogspot.com/

Attachment: http_endpoint.diff
Description: Binary data

<?xml version="1.0" encoding="UTF-8"?>
<endpoint xmlns="http://ws.apache.org/ns/synapse"; name="TestEP">
	<http uri-template="http://localhost:8080/{uri.var.servicepath}/restapi/{uri.var.servicename}/menu?category={uri.var.category}&amp;type={uri.var.pizzaType}";
          method="GET">

          </http>
</endpoint>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to