| <?xml version="1.0" encoding="ISO-8859-1" ?> |
| <!-- |
| ~ 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. |
| --> |
| |
| <document> |
| <properties> |
| <title>Apache Synapse - Sample 152</title> |
| </properties> |
| <body> |
| <section name="Sample 152: Switching Transports and Message Format from SOAP to REST/POX"> |
| <div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> |
| |
| <proxy name="StockQuoteProxy" transports="https"> |
| <target> |
| <endpoint> |
| <address uri="http://localhost:9000/services/SimpleStockQuoteService" format="pox"/> |
| </endpoint> |
| <outSequence> |
| <send/> |
| </outSequence> |
| </target> |
| <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/> |
| </proxy> |
| |
| </definitions></div> |
| <subsection name="Objective"> |
| <p> |
| Demonstrate implementing simple transport switching and message format switching |
| scenarios using proxy services |
| </p> |
| </subsection> |
| <subsection name="Pre-requisites"> |
| <p> |
| <ul> |
| <li> |
| Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2 |
| </li> |
| <li> |
| Start Synapse using the configuration numbered 152 (repository/conf/sample/synapse_sample_152.xml) |
| <div class="command"> |
| Unix/Linux: sh synapse.sh -sample 152<br/> |
| Windows: synapse.bat -sample 152 |
| </div> |
| </li> |
| </ul> |
| </p> |
| </subsection> |
| <subsection name="Executing the Client"> |
| <p> |
| This configuration demonstrates how a proxy service can be exposed on a subset |
| of available transports, and how it could switch from one transport to another. |
| This example exposes the created proxy service only on HTTPS, and thus if the |
| user tries to access it over HTTP, it would result in a fault. |
| </p> |
| <div class="consoleOutput">ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuoteProxy |
| ... |
| [java] org.apache.axis2.AxisFault: The service cannot be found for the endpoint reference (EPR) /soap/StockQuoteProxy</div> |
| |
| <p> |
| Accessing this over HTTPS causes the proxy service to access the SimpleStockQuoteService |
| on the sample Axis2 server using REST/POX. |
| </p> |
| <div class="command">ant stockquote -Dtrpurl=https://localhost:8243/services/StockQuoteProxy</div> |
| |
| <p> |
| TCPMon can be used to trace the actual REST/POX messages exchanged between Synapse |
| and the sample Axis2 server. Synapse converts the POX response back to SOAP before |
| sending it back to the client. |
| </p> |
| <div class="consoleOutput">POST /services/SimpleStockQuoteService HTTP/1.1 |
| Host: 127.0.0.1 |
| SOAPAction: urn:getQuote |
| Content-Type: application/xml; charset=UTF-8;action="urn:getQuote"; |
| Transfer-Encoding: chunked |
| Connection: Keep-Alive |
| User-Agent: Synapse-HttpComponents-NIO |
| |
| 75 |
| <m0:getQuote xmlns:m0="http://services.samples"> |
| <m0:request> |
| <m0:symbol>IBM</m0:symbol> |
| </m0:request> |
| </m0:getQuote></div> |
| |
| <div class="consoleOutput">HTTP/1.1 200 OK |
| Content-Type: application/xml; charset=UTF-8;action="http://services.samples/SimpleStockQuoteServicePortType/getQuoteResponse"; |
| Date: Tue, 24 Apr 2007 14:42:11 GMT |
| Server: Synapse-HttpComponents-NIO |
| Transfer-Encoding: chunked |
| Connection: Keep-Alive |
| |
| 2b3 |
| <ns:getQuoteResponse xmlns:ns="http://services.samples/xsd"> |
| <ns:return> |
| <ns:change>3.7730036841862384</ns:change> |
| <ns:earnings>-9.950236235550818</ns:earnings> |
| <ns:high>-80.23868444613285</ns:high> |
| <ns:last>80.50750970812187</ns:last> |
| <ns:lastTradeTimestamp>Tue Apr 24 20:42:11 LKT 2007</ns:lastTradeTimestamp> |
| <ns:low>-79.67368355714606</ns:low> |
| <ns:marketCap>4.502043663670823E7</ns:marketCap> |
| <ns:name>IBM Company</ns:name> |
| <ns:open>-80.02229531286982</ns:open> |
| <ns:peRatio>25.089295161182022</ns:peRatio> |
| <ns:percentageChange>4.28842665653824</ns:percentageChange> |
| <ns:prevClose>87.98107059692451</ns:prevClose> |
| <ns:symbol>IBM</ns:symbol> |
| <ns:volume>19941</ns:volume> |
| </ns:return> |
| </ns:getQuoteResponse></div> |
| |
| </subsection> |
| </section> |
| <p><a href="../samples.html">Back to Catalog</a></p> |
| </body> |
| </document> |