FYI.

With the recent changes in synapse core[1] now we handle service chaining
scenarios with less complexity with ESB.
Here is an example, where we have a service chain of 2 services. (We can
specify the receiving sequence while sending.)

<definitions xmlns="http://ws.apache.org/ns/synapse";>
    <proxy name="HCProxy">
        <target>
            <inSequence>
                <!--Create the message to be sent to the SERVICE-I and
replace SOAPBody with it-->


                <!--Sending by specifying the receiving seq-->
                <send receive="HCSeq">
                    <endpoint>
                        <address uri="
http://localhost:9764/services/GeoService/"/>
                    </endpoint>
                </send>
            </inSequence>
            <outSequence>
                <log/>
            </outSequence>
        </target>
    </proxy>


    <sequence name="HCSeq">
        <log>
            <property name="MSG_FLOW" value="HCSeq"/>
        </log>


        <!--Create the message to be sent to the SERVICE-II and replace
SOAPBody with it-->


        <!--Sending by specifying the receiving seq-->
        <send receive="ClientOutSeq">
            <endpoint name="HealthCareEP">
                <address uri="http://localhost:9764/services/GeoHCService/
"/>
            </endpoint>
        </send>
    </sequence>


    <sequence name="ClientOutSeq">
        <log level="full"/>
        <!--Send Back-->
        <send/>
    </sequence>


</definitions>


[1] https://issues.apache.org/jira/browse/SYNAPSE-593

(Full working config attached)

Thanks.
-- 
Kasun Indrasiri
Senior Software Engineer
WSO2, Inc.; http://wso2.com
lean.enterprise.middleware

cell: +94 71 536 4128
Blog : http://kasunpanorama.blogspot.com/
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~  Licensed to the Apache Software Foundation (ASF) under one
  ~  or more contributor license agreements.  See the NOTICE file
  ~  distributed with this work for additional information
  ~  regarding copyright ownership.  The ASF licenses this file
  ~  to you under the Apache License, Version 2.0 (the
  ~  "License"); you may not use this file except in compliance
  ~  with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~  Unless required by applicable law or agreed to in writing,
  ~  software distributed under the License is distributed on an
  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~  KIND, either express or implied.  See the License for the
  ~  specific language governing permissions and limitations
  ~  under the License.
  -->

<definitions xmlns="http://ws.apache.org/ns/synapse";>

    <proxy name="HCProxy">
        <target>
            <inSequence>

                <enrich>
                    <source type="custom"
                            xpath="//hcp:getHCCenterInfo/hcp:longitude"
                            xmlns:hcp="http://HCProxy.wso2"/>
                    <target type="property" property="LONGITUDE"/>
                </enrich>
                <enrich>
                    <source type="custom"
                            xpath="//hcp:getHCCenterInfo/hcp:latitude"
                            xmlns:hcp="http://HCProxy.wso2"/>
                    <target type="property" property="LATITUDE"/>
                </enrich>
                <enrich>
                    <source type="inline">
                        <geo:getZipCode xmlns:geo="http://geo.wso2";>
                            <geo:longitude>0</geo:longitude>
                            <geo:latitude>0</geo:latitude>
                        </geo:getZipCode>
                    </source>
                    <target type="body"/>
                </enrich>
                <enrich>
                    <source type="property" property="LONGITUDE"/>
                    <target xmlns:geo="http://geo.wso2";
                            xpath="//geo:getZipCode/geo:longitude"/>
                </enrich>
                <enrich>
                    <source type="property" property="LATITUDE"/>
                    <target xmlns:geo="http://geo.wso2";
                            xpath="//geo:getZipCode/geo:latitude"/>
                </enrich>

                <send receive="HCSeq">
                    <endpoint>
                        <address uri="http://localhost:9764/services/GeoService/"/>
                    </endpoint>
                </send>

            </inSequence>
            <outSequence>
                <send/>
            </outSequence>
        </target>
    </proxy>


    <sequence name="HCSeq">
        <log>
            <property name="MSG_FLOW" value="HCSeq"/>
        </log>

        <enrich>
            <source type="custom"
                    xpath="//ns:getZipCodeResponse/ns:return/text()"
                    xmlns:ns="http://geo.wso2"/>
            <target type="property" property="ZIP_CODE"/>
        </enrich>
        <enrich>
            <source type="inline">
                <hcc:getHealthCareCenterInfo xmlns:hcc="http://hcc.wso2";>
                    <hcc:zipCode>foo</hcc:zipCode>
                </hcc:getHealthCareCenterInfo>
            </source>
            <target type="body"/>
        </enrich>
        <enrich>
            <source type="property" property="ZIP_CODE"/>
            <target xmlns:hcc="http://hcc.wso2";
                    xpath="//hcc:getHealthCareCenterInfo/hcc:zipCode"/>
        </enrich>
        <send receive="ClientOutSeq">
            <endpoint name="HealthCareEP">
                <address uri="http://localhost:9764/services/GeoHCService/"/>
            </endpoint>
        </send>

    </sequence>

    <sequence name="ClientOutSeq">
        <log level="full"/>
        <send/>
    </sequence>

</definitions>
_______________________________________________
Carbon-dev mailing list
Carbon-dev@wso2.org
http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev

Reply via email to