You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2007/04/20 10:20:47 UTC
svn commit: r530689 - in /webservices/synapse/trunk/java:
modules/samples/services/MTOMSwASampleService/src/samples/services/
modules/samples/services/SecureStockQuoteService/
modules/samples/services/SecureStockQuoteService/conf/
modules/samples/servi...
Author: asankha
Date: Fri Apr 20 01:20:43 2007
New Revision: 530689
URL: http://svn.apache.org/viewvc?view=rev&rev=530689
Log:
streamlining samples - take 2
add samples for MTOM/SwA
Added:
webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetFullQuote.java
webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetFullQuoteResponse.java
webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetMarketActivity.java
webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetMarketActivityResponse.java
webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/TradingDay.java
webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/wsdl/
webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/wsdl/SimpleStockQuoteService.wsdl
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_12.xml
Removed:
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/common/Util.java
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/CustomStockQuoteClient.java
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/DumbStockQuoteClient.java
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/PlaceOrderClient.java
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/ProxyStockQuoteClient.java
Modified:
webservices/synapse/trunk/java/modules/samples/services/MTOMSwASampleService/src/samples/services/MTOMSwASampleService.java
webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/build.xml
webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/conf/services.xml
webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/SimpleStockQuoteService.java
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/common/StockQuoteHandler.java
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/GenericJMSClient.java
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/StockQuoteClient.java
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/util/SampleAxis2Server.java
webservices/synapse/trunk/java/modules/samples/src/main/scripts/build.xml
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_105.xml
Modified: webservices/synapse/trunk/java/modules/samples/services/MTOMSwASampleService/src/samples/services/MTOMSwASampleService.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/services/MTOMSwASampleService/src/samples/services/MTOMSwASampleService.java?view=diff&rev=530689&r1=530688&r2=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/services/MTOMSwASampleService/src/samples/services/MTOMSwASampleService.java (original)
+++ webservices/synapse/trunk/java/modules/samples/services/MTOMSwASampleService/src/samples/services/MTOMSwASampleService.java Fri Apr 20 01:20:43 2007
@@ -71,6 +71,12 @@
response.addChild(image);
payload.addChild(response);
+ MessageContext outMsgCtx = MessageContext.getCurrentMessageContext()
+ .getOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ outMsgCtx.setProperty(
+ org.apache.axis2.Constants.Configuration.ENABLE_MTOM,
+ org.apache.axis2.Constants.VALUE_TRUE);
+
return payload;
}
@@ -93,6 +99,9 @@
MessageContext outMsgCtx = msgCtx.getOperationContext().
getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ outMsgCtx.setProperty(
+ org.apache.axis2.Constants.Configuration.ENABLE_SWA,
+ org.apache.axis2.Constants.VALUE_TRUE);
OMFactory factory = request.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://www.apache-synapse.org/test", "m0");
@@ -108,5 +117,26 @@
payload.addChild(response);
return payload;
+ }
+
+ public void oneWayUploadUsingMTOM(OMElement element) throws Exception {
+
+ OMText binaryNode = (OMText) element.getFirstOMChild();
+ DataHandler dataHandler = (DataHandler) binaryNode.getDataHandler();
+ InputStream is = dataHandler.getInputStream();
+
+ File tempFile = File.createTempFile("mtom-", ".gif");
+ FileOutputStream fos = new FileOutputStream(tempFile);
+ BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);
+
+ byte data[] = new byte[BUFFER];
+ int count;
+ while ((count = is.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, count);
+ }
+
+ dest.flush();
+ dest.close();
+ System.out.println("Wrote to file : " + tempFile.getAbsolutePath());
}
}
Modified: webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/build.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/build.xml?view=diff&rev=530689&r1=530688&r2=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/build.xml (original)
+++ webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/build.xml Fri Apr 20 01:20:43 2007
@@ -56,6 +56,7 @@
<mkdir dir="${SSQ.dir}/META-INF"/>
<copy file="conf/services.xml" tofile="${SSQ.dir}/META-INF/services.xml"/>
+ <copy file="wsdl/SimpleStockQuoteService.wsdl" tofile="${SSQ.dir}/META-INF/service.wsdl"/>
<copy file="store.jks" tofile="${SSQ.dir}/store.jks"/>
<copy toDir="${SSQ.dir}">
<fileset dir="${classes}">
Modified: webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/conf/services.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/conf/services.xml?view=diff&rev=530689&r1=530688&r2=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/conf/services.xml (original)
+++ webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/conf/services.xml Fri Apr 20 01:20:43 2007
@@ -21,13 +21,13 @@
<service name="SecureStockQuoteService">
<module ref="rampart"/>
- <messageReceivers>
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
- class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
- <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
- class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
- </messageReceivers>
- <parameter locked="false" name="ServiceClass">samples.services.SimpleStockQuoteService</parameter>
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/ns/wsdl/in-only"
+ class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
+ <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
+ class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
+ </messageReceivers>
+ <parameter locked="false" name="ServiceClass">samples.services.SimpleStockQuoteService</parameter>
<wsp:Policy wsu:Id="SigEncr" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:ExactlyOne>
Added: webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetFullQuote.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetFullQuote.java?view=auto&rev=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetFullQuote.java (added)
+++ webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetFullQuote.java Fri Apr 20 01:20:43 2007
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package samples.services;
+
+public class GetFullQuote {
+ String symbol;
+
+ public GetFullQuote() {
+ }
+
+ public GetFullQuote(String symbol) {
+ this.symbol = symbol;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+}
\ No newline at end of file
Added: webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetFullQuoteResponse.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetFullQuoteResponse.java?view=auto&rev=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetFullQuoteResponse.java (added)
+++ webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetFullQuoteResponse.java Fri Apr 20 01:20:43 2007
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+package samples.services;
+
+public class GetFullQuoteResponse {
+
+ private static final int COUNT = 365;
+ TradingDay[] tradeHistory = null;
+
+ public GetFullQuoteResponse() {
+ }
+
+ public GetFullQuoteResponse(String symbol) {
+ tradeHistory = new TradingDay[COUNT];
+ for (int i=0; i<COUNT; i++) {
+ tradeHistory[i] = new TradingDay(i, new GetQuoteResponse(symbol));
+ }
+ }
+
+ public TradingDay[] getTradeHistory() {
+ return tradeHistory;
+ }
+
+ public void setTradeHistory(TradingDay[] tradeHistory) {
+ this.tradeHistory = tradeHistory;
+ }
+
+}
Added: webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetMarketActivity.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetMarketActivity.java?view=auto&rev=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetMarketActivity.java (added)
+++ webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetMarketActivity.java Fri Apr 20 01:20:43 2007
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package samples.services;
+
+public class GetMarketActivity {
+ String[] symbols;
+
+ public GetMarketActivity() {
+ }
+
+ public GetMarketActivity(String[] symbols) {
+ this.symbols = symbols;
+ }
+
+ public String[] getSymbols() {
+ return symbols;
+ }
+
+ public void setSymbols(String[] symbols) {
+ this.symbols = symbols;
+ }
+}
\ No newline at end of file
Added: webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetMarketActivityResponse.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetMarketActivityResponse.java?view=auto&rev=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetMarketActivityResponse.java (added)
+++ webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/GetMarketActivityResponse.java Fri Apr 20 01:20:43 2007
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+package samples.services;
+
+public class GetMarketActivityResponse {
+
+ GetQuoteResponse[] quotes = null;
+
+ public GetMarketActivityResponse() {
+ }
+
+ public GetMarketActivityResponse(String[] symbols) {
+ quotes = new GetQuoteResponse[symbols.length];
+ for (int i=0; i<symbols.length; i++) {
+ quotes[i] = new GetQuoteResponse(symbols[i]);
+ }
+ }
+
+ public GetQuoteResponse[] getQuotes() {
+ return quotes;
+ }
+
+ public void setQuotes(GetQuoteResponse[] quotes) {
+ this.quotes = quotes;
+ }
+}
Modified: webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/SimpleStockQuoteService.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/SimpleStockQuoteService.java?view=diff&rev=530689&r1=530688&r2=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/SimpleStockQuoteService.java (original)
+++ webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/SimpleStockQuoteService.java Fri Apr 20 01:20:43 2007
@@ -23,14 +23,39 @@
// in-out
public GetQuoteResponse getQuote(GetQuote request) {
- System.out.println(new Date() + " :: Generating quote for : " + request.getSymbol());
+ System.out.println(new Date() + " " + this.getClass().getName() +
+ " :: Generating quote for : " + request.getSymbol());
return new GetQuoteResponse(request.getSymbol());
}
+ // in-out large response
+ public GetFullQuoteResponse getFullQuote(GetFullQuote request) {
+ System.out.println(new Date() + " " + this.getClass().getName() +
+ " :: Full quote for : " + request.getSymbol());
+ return new GetFullQuoteResponse(request.getSymbol());
+ }
+
+ // in-out large request and response
+ public GetMarketActivityResponse getMarketActivity(GetMarketActivity request) {
+ StringBuffer sb = new StringBuffer();
+ String[] symbols = request.getSymbols();
+ sb.append("[");
+ for (int i=0; i<symbols.length; i++) {
+ sb.append(symbols[i]);
+ if (i < symbols.length-1) {
+ sb.append(", ");
+ }
+ }
+ sb.append("]");
+ System.out.println(new Date() + " " + this.getClass().getName() +
+ " :: Generating Market activity report for : " + sb.toString());
+ return new GetMarketActivityResponse(request.getSymbols());
+ }
+
// in only
public void placeOrder(PlaceOrder order) {
- System.out.println(new Date() + " :: Accepted order for : " +
- order.getQuantity() + " stocks of " + order.getSymbol() +
- " at $ " + order.getPrice());
+ System.out.println(new Date() + " " + this.getClass().getName() +
+ " :: Accepted order for : " + order.getQuantity() +
+ " stocks of " + order.getSymbol() + " at $ " + order.getPrice());
}
}
Added: webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/TradingDay.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/TradingDay.java?view=auto&rev=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/TradingDay.java (added)
+++ webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/src/samples/services/TradingDay.java Fri Apr 20 01:20:43 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+package samples.services;
+
+public class TradingDay {
+ int day = 0;
+ GetQuoteResponse quote = null;
+
+ public TradingDay(int day, GetQuoteResponse quote) {
+ this.day = day;
+ this.quote = quote;
+ }
+
+ public int getDay() {
+ return day;
+ }
+
+ public void setDay(int day) {
+ this.day = day;
+ }
+
+ public GetQuoteResponse getQuote() {
+ return quote;
+ }
+
+ public void setQuote(GetQuoteResponse quote) {
+ this.quote = quote;
+ }
+}
\ No newline at end of file
Added: webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/wsdl/SimpleStockQuoteService.wsdl
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/wsdl/SimpleStockQuoteService.wsdl?view=auto&rev=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/wsdl/SimpleStockQuoteService.wsdl (added)
+++ webservices/synapse/trunk/java/modules/samples/services/SecureStockQuoteService/wsdl/SimpleStockQuoteService.wsdl Fri Apr 20 01:20:43 2007
@@ -0,0 +1,290 @@
+<!--
+ ~ 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.
+ -->
+
+<wsdl:definitions xmlns:axis2="http://services.samples"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:ns0="http://services.samples/xsd"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:ns1="http://org.apache.axis2/xsd"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ targetNamespace="http://services.samples">
+ <wsdl:documentation>SimpleStockQuoteService</wsdl:documentation>
+ <wsdl:types>
+ <xs:schema xmlns:ns="http://services.samples/xsd" attributeFormDefault="qualified"
+ elementFormDefault="qualified" targetNamespace="http://services.samples/xsd">
+ <xs:element name="getFullQuote">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="request" nillable="true" type="ns:GetFullQuote"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="GetFullQuote" type="ns:GetFullQuote"/>
+ <xs:complexType name="GetFullQuote">
+ <xs:sequence>
+ <xs:element name="symbol" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="getFullQuoteResponse">
+ <xs:complexType>
+
+ <xs:sequence>
+ <xs:element name="return" nillable="true" type="ns:GetFullQuoteResponse"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="GetFullQuoteResponse" type="ns:GetFullQuoteResponse"/>
+ <xs:complexType name="GetFullQuoteResponse">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="tradeHistory" nillable="true"
+ type="ns:TradingDay"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="TradingDay" type="ns:TradingDay"/>
+ <xs:complexType name="TradingDay">
+ <xs:sequence>
+ <xs:element name="day" type="xs:int"/>
+ <xs:element name="quote" nillable="true" type="ns:GetQuoteResponse"/>
+ </xs:sequence>
+
+ </xs:complexType>
+ <xs:element name="GetQuoteResponse" type="ns:GetQuoteResponse"/>
+ <xs:complexType name="GetQuoteResponse">
+ <xs:sequence>
+ <xs:element name="change" type="xs:double"/>
+ <xs:element name="earnings" type="xs:double"/>
+ <xs:element name="high" type="xs:double"/>
+ <xs:element name="last" type="xs:double"/>
+ <xs:element name="lastTradeTimestamp" nillable="true" type="xs:string"/>
+ <xs:element name="low" type="xs:double"/>
+ <xs:element name="marketCap" type="xs:double"/>
+ <xs:element name="name" nillable="true" type="xs:string"/>
+ <xs:element name="open" type="xs:double"/>
+ <xs:element name="peRatio" type="xs:double"/>
+ <xs:element name="percentageChange" type="xs:double"/>
+ <xs:element name="prevClose" type="xs:double"/>
+ <xs:element name="symbol" nillable="true" type="xs:string"/>
+
+ <xs:element name="volume" type="xs:int"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="getMarketActivity">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="request" nillable="true" type="ns:GetMarketActivity"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="GetMarketActivity" type="ns:GetMarketActivity"/>
+ <xs:complexType name="GetMarketActivity">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="symbols" nillable="true"
+ type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="getMarketActivityResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" nillable="true"
+ type="ns:GetMarketActivityResponse"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="GetMarketActivityResponse" type="ns:GetMarketActivityResponse"/>
+ <xs:complexType name="GetMarketActivityResponse">
+ <xs:sequence/>
+ </xs:complexType>
+ <xs:element name="getQuote">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="request" nillable="true" type="ns:GetQuote"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="GetQuote" type="ns:GetQuote"/>
+ <xs:complexType name="GetQuote">
+ <xs:sequence>
+ <xs:element name="symbol" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="getQuoteResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" nillable="true" type="ns:GetQuoteResponse"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="placeOrder">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="order" nillable="true" type="ns:PlaceOrder"/>
+
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="PlaceOrder" type="ns:PlaceOrder"/>
+ <xs:complexType name="PlaceOrder">
+ <xs:sequence>
+ <xs:element name="price" type="xs:double"/>
+ <xs:element name="quantity" type="xs:int"/>
+ <xs:element name="symbol" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="placeOrderMessage">
+ <wsdl:part name="part1" element="ns0:placeOrder"/>
+ </wsdl:message>
+ <wsdl:message name="getQuoteMessage">
+ <wsdl:part name="part1" element="ns0:getQuote"/>
+ </wsdl:message>
+ <wsdl:message name="getQuoteResponse">
+ <wsdl:part name="part1" element="ns0:getQuoteResponse"/>
+ </wsdl:message>
+ <wsdl:message name="getMarketActivityMessage">
+ <wsdl:part name="part1" element="ns0:getMarketActivity"/>
+ </wsdl:message>
+ <wsdl:message name="getMarketActivityResponse">
+ <wsdl:part name="part1" element="ns0:getMarketActivityResponse"/>
+ </wsdl:message>
+ <wsdl:message name="getFullQuoteMessage">
+ <wsdl:part name="part1" element="ns0:getFullQuote"/>
+ </wsdl:message>
+ <wsdl:message name="getFullQuoteResponse">
+ <wsdl:part name="part1" element="ns0:getFullQuoteResponse"/>
+ </wsdl:message>
+ <wsdl:portType name="SimpleStockQuoteServicePortType">
+ <wsdl:operation name="placeOrder">
+ <wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ message="axis2:placeOrderMessage" wsaw:Action="urn:placeOrder"/>
+ </wsdl:operation>
+ <wsdl:operation name="getQuote">
+ <wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ message="axis2:getQuoteMessage" wsaw:Action="urn:getQuote"/>
+ <wsdl:output message="axis2:getQuoteResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="getMarketActivity">
+ <wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ message="axis2:getMarketActivityMessage"
+ wsaw:Action="urn:getMarketActivity"/>
+ <wsdl:output message="axis2:getMarketActivityResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="getFullQuote">
+ <wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ message="axis2:getFullQuoteMessage" wsaw:Action="urn:getFullQuote"/>
+ <wsdl:output message="axis2:getFullQuoteResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="SimpleStockQuoteServiceSOAP11Binding"
+ type="axis2:SimpleStockQuoteServicePortType">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <wsdl:operation name="placeOrder">
+ <soap:operation soapAction="urn:placeOrder" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ <wsdl:operation name="getQuote">
+ <soap:operation soapAction="urn:getQuote" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getMarketActivity">
+ <soap:operation soapAction="urn:getMarketActivity" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getFullQuote">
+ <soap:operation soapAction="urn:getFullQuote" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="SimpleStockQuoteServiceSOAP12Binding"
+ type="axis2:SimpleStockQuoteServicePortType">
+ <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <wsdl:operation name="placeOrder">
+ <soap12:operation soapAction="urn:placeOrder" style="document"/>
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ <wsdl:operation name="getQuote">
+ <soap12:operation soapAction="urn:getQuote" style="document"/>
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getMarketActivity">
+ <soap12:operation soapAction="urn:getMarketActivity" style="document"/>
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getFullQuote">
+ <soap12:operation soapAction="urn:getFullQuote" style="document"/>
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="SimpleStockQuoteService">
+ <wsdl:port name="SimpleStockQuoteServiceSOAP11port_https"
+ binding="axis2:SimpleStockQuoteServiceSOAP11Binding">
+ <soap:address location="https://asankha:9002/axis2/services/SimpleStockQuoteService"/>
+ </wsdl:port>
+ <wsdl:port name="SimpleStockQuoteServiceSOAP11port_http1"
+ binding="axis2:SimpleStockQuoteServiceSOAP11Binding">
+ <soap:address location="http://asankha:9000/axis2/services/SimpleStockQuoteService"/>
+ </wsdl:port>
+ <wsdl:port name="SimpleStockQuoteServiceSOAP12port_https"
+ binding="axis2:SimpleStockQuoteServiceSOAP12Binding">
+ <soap12:address location="https://asankha:9002/axis2/services/SimpleStockQuoteService"/>
+ </wsdl:port>
+ <wsdl:port name="SimpleStockQuoteServiceSOAP12port_http1"
+ binding="axis2:SimpleStockQuoteServiceSOAP12Binding">
+ <soap12:address location="http://asankha:9000/axis2/services/SimpleStockQuoteService"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file
Modified: webservices/synapse/trunk/java/modules/samples/src/main/java/samples/common/StockQuoteHandler.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/src/main/java/samples/common/StockQuoteHandler.java?view=diff&rev=530689&r1=530688&r2=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/src/main/java/samples/common/StockQuoteHandler.java (original)
+++ webservices/synapse/trunk/java/modules/samples/src/main/java/samples/common/StockQuoteHandler.java Fri Apr 20 01:20:43 2007
@@ -23,22 +23,29 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.xpath.AXIOMXPath;
import javax.xml.namespace.QName;
+import java.util.Random;
+import java.util.List;
+import java.util.Iterator;
/**
* A class that can create messages to, and parse replies from our sample StockQuote service
*/
public class StockQuoteHandler {
+
+ private static final Random RANDOM = new Random();
+
/**
- * Create a new custom stock quote request with a body as follows
+ * Create a new custom quote request with a body as follows
* <m0:CheckPriceRequest xmlns:m0="http://www.apache-synapse.org/test">
* <m0:Code>symbol</m0:Code>
* </m0:CheckPriceRequest>
* @param symbol the stock symbol
* @return OMElement for SOAP body
*/
- public static OMElement createCustomRequestPayload(String symbol) {
+ public static OMElement createCustomQuoteRequest(String symbol) {
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace(
"http://www.apache-synapse.org/test", "m0");
@@ -50,38 +57,41 @@
}
/**
- * Create a new erroneous custom stock quote request with a body as follows
- * <m0:CheckPriceRequest xmlns:m0="http://www.apache-synapse.org/test">
- * <m0:Symbol>symbol</m0:Symbol>
- * </m0:CheckPriceRequest>
+ * Create a new quote request with a body as follows
+ * <m:GetQuote xmlns:m="http://services.samples/xsd">
+ * <m:request>
+ * <m:symbol>IBM</m:symbol>
+ * </m:request>
+ * </m:GetQuote>
* @param symbol the stock symbol
* @return OMElement for SOAP body
*/
- public static OMElement createErroneousCustomRequestPayload(String symbol) {
+ public static OMElement createStandardQuoteRequest(String symbol) {
OMFactory factory = OMAbstractFactory.getOMFactory();
- OMNamespace ns = factory.createOMNamespace(
- "http://www.apache-synapse.org/test", "m0");
- OMElement chkPrice = factory.createOMElement("CheckPriceRequest", ns);
- OMElement code = factory.createOMElement("Symbol", ns);
- chkPrice.addChild(code);
- code.setText(symbol);
- return chkPrice;
+ OMNamespace ns = factory.createOMNamespace("http://services.samples/xsd", "m0");
+ OMElement getQuote = factory.createOMElement("getQuote", ns);
+ OMElement request = factory.createOMElement("request", ns);
+ OMElement symb = factory.createOMElement("symbol", ns);
+ request.addChild(symb);
+ getQuote.addChild(request);
+ symb.setText(symbol);
+ return getQuote;
}
/**
- * Create a new custom stock quote request with a body as follows
- * <m:GetQuote xmlns:m="http://services.samples/xsd">
+ * Create a new full quote request with a body as follows
+ * <m:GetFullQuote xmlns:m="http://services.samples/xsd">
* <m:request>
* <m:symbol>IBM</m:symbol>
* </m:request>
- * </m:GetQuote>
+ * </m:GetFullQuote>
* @param symbol the stock symbol
* @return OMElement for SOAP body
*/
- public static OMElement createStandardRequestPayload(String symbol) {
+ public static OMElement createFullQuoteRequest(String symbol) {
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://services.samples/xsd", "m0");
- OMElement getQuote = factory.createOMElement("getQuote", ns);
+ OMElement getQuote = factory.createOMElement("getFullQuote", ns);
OMElement request = factory.createOMElement("request", ns);
OMElement symb = factory.createOMElement("symbol", ns);
request.addChild(symb);
@@ -91,6 +101,34 @@
}
/**
+ * Create a new market activity request with a body as follows
+ * <m:getMarketActivity xmlns:m="http://services.samples/xsd">
+ * <m:request>
+ * <m:symbol>IBM</m:symbol>
+ * ...
+ * <m:symbol>MSFT</m:symbol>
+ * </m:request>
+ * </m:getMarketActivity>
+ * @return OMElement for SOAP body
+ */
+ public static OMElement createMarketActivityRequest() {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMNamespace ns = factory.createOMNamespace("http://services.samples/xsd", "m0");
+ OMElement getQuote = factory.createOMElement("getMarketActivity", ns);
+ OMElement request = factory.createOMElement("request", ns);
+
+ OMElement symb = null;
+ for (int i=0; i<100; i++) {
+ symb = factory.createOMElement("symbols", ns);
+ symb.setText(randomString(3));
+ request.addChild(symb);
+ }
+
+ getQuote.addChild(request);
+ return getQuote;
+ }
+
+ /**
* Create a new order for a quantiry of a stock at a given price
* <m:placeOrder xmlns:m="http://services.samples/xsd">
* <m:order>
@@ -105,7 +143,7 @@
* @param symbol the stock
* @return an OMElement payload for the order
*/
- public static OMElement createPlaceOrderPayload(double purchPrice, int qty, String symbol) {
+ public static OMElement createPlaceOrderRequest(double purchPrice, int qty, String symbol) {
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://services.samples/xsd", "m0");
OMElement placeOrder= factory.createOMElement("placeOrder", ns);
@@ -138,10 +176,11 @@
* </ns:return>
* </ns:getQuoteResponse>
*/
- public static String parseStandardResponsePayload(OMElement result) throws Exception {
+ public static String parseStandardQuoteResponse(OMElement result) throws Exception {
- OMElement last = result.getFirstChildWithName(
- new QName("http://services.samples/xsd", "last"));
+ AXIOMXPath xPath = new AXIOMXPath("//ns:last");
+ xPath.addNamespace("ns","http://services.samples/xsd");
+ OMElement last = (OMElement) xPath.selectSingleNode(result);
if (last != null) {
return last.getText();
} else {
@@ -150,6 +189,131 @@
}
/**
+ * <ns:getFullQuoteResponse xmlns:ns="http://services.samples/xsd">
+ <ns:return>
+ <tradeHistory xmlns="http://services.samples/xsd">
+ <day>0</day>
+ <quote>
+ <change>-2.367492989603466</change>
+ <earnings>13.14956711287784</earnings>
+ <high>-155.58844623078153</high>
+ <last>157.47582716569198</last>
+ <lastTradeTimestamp>Mon Apr 16 23:29:58 LKT 2007</lastTradeTimestamp>
+ <low>-155.31924118819015</low>
+ <marketCap>6373750.467022192</marketCap>
+ <name>IBM Company</name>
+ <open>-154.84071720443495</open>
+ <peRatio>-17.353258031353164</peRatio>
+ <percentageChange>-1.3910235348298898</percentageChange>
+ <prevClose>170.1979104108393</prevClose>
+ <symbol>IBM</symbol>
+ <volume>8935</volume>
+ </quote>
+ </tradeHistory>
+ <tradeHistory xmlns="http://services.samples/xsd">
+ <day>1</day>
+ <quote>
+ <change>3.794122022240518</change>
+ <earnings>-8.656536789776045</earnings>
+ <high>176.77136802352928</high>
+ <last>170.28677783945102</last>
+ <lastTradeTimestamp>Mon Apr 16 23:29:58 LKT 2007</lastTradeTimestamp>
+ <low>-166.64126635049223</low>
+ <marketCap>-6112014.916847887</marketCap>
+ <name>IBM Company</name>
+ <open>-168.30884678174925</open>
+ <peRatio>-18.644628475049693</peRatio>
+ <percentageChange>-2.29678289479374</percentageChange>
+ <prevClose>-165.19288918603885</prevClose>
+ <symbol>IBM</symbol>
+ <volume>5825</volume>
+ </quote>
+ </tradeHistory>
+ ...
+ </ns:return>
+ </ns:getFullQuoteResponse>
+ *
+ * @param result
+ * @return
+ * @throws Exception
+ */
+ public static String parseFullQuoteResponse(OMElement result) throws Exception {
+
+ AXIOMXPath xPath = new AXIOMXPath("//ns:last");
+ xPath.addNamespace("ns","http://services.samples/xsd");
+ List lastNodes = xPath.selectNodes(result);
+
+ if (lastNodes == null) {
+ throw new Exception("Unexpected response : " + result);
+ }
+
+ double total = 0;
+ int count = 0;
+
+ Iterator iter = lastNodes.iterator();
+ while (iter.hasNext()) {
+ OMElement last = (OMElement) iter.next();
+ total += Double.parseDouble(last.getText());
+ count++;
+ }
+
+ return Double.toString(total/count);
+ }
+
+ /**
+ * <ns:getMarketActivityResponse xmlns:ns="http://services.samples/xsd">
+ <ns:return>
+ <quotes xmlns="http://services.samples/xsd">
+ <change>4.183958555301184</change>
+ <earnings>-8.585281368244686</earnings>
+ <high>-158.70528805517333</high>
+ <last>160.83784480071603</last>
+ <lastTradeTimestamp>Tue Apr 17 02:21:30 LKT 2007</lastTradeTimestamp>
+ <low>-157.4950051860593</low>
+ <marketCap>5.9907588733164035E7</marketCap>
+ <name>EHM Company</name>
+ <open>-160.18368223376558</open>
+ <peRatio>24.0926205053427</peRatio>
+ <percentageChange>-2.6141745708181374</percentageChange>
+ <prevClose>-160.04893483420904</prevClose>
+ <symbol>EHM</symbol>
+ <volume>6319</volume>
+ </quotes>
+ <quotes xmlns="http://services.samples/xsd">
+ ....
+ <volume>7613</volume>
+ </quotes>
+ ...
+ </ns:return>
+ <ns:getMarketActivityResponse>
+ * @param result
+ * @return the average last price for each stock symbol
+ * @throws Exception
+ */
+ public static String parseMarketActivityResponse(OMElement result) throws Exception {
+
+ AXIOMXPath xPath = new AXIOMXPath("//ns:last");
+ xPath.addNamespace("ns","http://services.samples/xsd");
+ List lastNodes = xPath.selectNodes(result);
+
+ if (lastNodes == null) {
+ throw new Exception("Unexpected response : " + result);
+ }
+
+ double total = 0;
+ int count = 0;
+
+ Iterator iter = lastNodes.iterator();
+ while (iter.hasNext()) {
+ OMElement last = (OMElement) iter.next();
+ total += Double.parseDouble(last.getText());
+ count++;
+ }
+
+ return Double.toString(total/count);
+ }
+
+ /**
* Digests the custom quote response and extracts the last trade price
* @param result
* @return
@@ -160,14 +324,40 @@
* <Price>82.90</Price>
* </CheckPriceResponse>
*/
- public static String parseCustomResponsePayload(OMElement result) throws Exception {
+ public static String parseCustomQuoteResponse(OMElement result) throws Exception {
- OMElement price = result.getFirstChildWithName(
- new QName("http://www.apache-synapse.org/test", "Price"));
+ AXIOMXPath xPath = new AXIOMXPath("//ns:Price");
+ xPath.addNamespace("ns","http://www.apache-synapse.org/test");
+ OMElement price = (OMElement) xPath.selectSingleNode(result);
if (price != null) {
return price.getText();
} else {
throw new Exception("Unexpected response : " + result);
}
}
+
+ /**
+ * Return a random String of letters
+ * @param count number of letters
+ * @return the random string
+ */
+ public static String randomString(int count) {
+ int end = 'Z' + 1;
+ int start = 'A';
+
+ StringBuffer buffer = new StringBuffer();
+ int gap = end - start;
+
+ while (count-- != 0) {
+ char ch;
+ ch = (char) (RANDOM.nextInt(gap) + start);
+ if (Character.isLetter(ch)) {
+ buffer.append(ch);
+ } else {
+ count++;
+ }
+ }
+ return buffer.toString();
+ }
+
}
Modified: webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/GenericJMSClient.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/GenericJMSClient.java?view=diff&rev=530689&r1=530688&r2=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/GenericJMSClient.java (original)
+++ webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/GenericJMSClient.java Fri Apr 20 01:20:43 2007
@@ -46,7 +46,7 @@
app.sendTextMessage(dest, param);
} else if ("binary".equalsIgnoreCase(type)) {
app.sendBytesMessage(dest, getBytesFromFile(param));
- } else if ("xml".equalsIgnoreCase(type)) {
+ } else if ("pox".equalsIgnoreCase(type)) {
app.sendTextMessage(dest,
"<m:placeOrder xmlns:m=\"http://services.samples/xsd\">\n" +
" <m:order>\n" +
Added: webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java?view=auto&rev=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java (added)
+++ webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/MTOMSwAClient.java Fri Apr 20 01:20:43 2007
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+
+package samples.userguide;
+
+import org.apache.axiom.om.*;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.attachments.Attachments;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.Constants;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.context.MessageContext;
+
+import javax.activation.FileDataSource;
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import java.io.*;
+
+public class MTOMSwAClient {
+
+ private static final int BUFFER = 2048;
+
+ public static void main(String[] args) throws Exception {
+
+ String targetEPR = "http://localhost:8080/axis2/services/MTOMSwASampleService";
+ String fileName = "./../../repository/conf/sample/resources/mtom/asf-logo.gif";
+ String mode = "mtom";
+
+ if (args.length > 0) mode = args[0];
+ if (args.length > 1) targetEPR = args[1];
+ if (args.length > 2) fileName = args[2];
+
+ if ("mtom".equals(mode)) {
+ sendUsingMTOM(fileName, targetEPR);
+ } else if ("swa".equals(mode)) {
+ sendUsingSwA(fileName, targetEPR);
+ }
+ }
+
+ private static void sendUsingSwA(String fileName, String targetEPR) throws IOException {
+
+ Options options = new Options();
+ options.setTo(new EndpointReference(targetEPR));
+ options.setAction("urn:uploadFileUsingSwA");
+ options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);
+
+ ServiceClient sender = new ServiceClient();
+ sender.setOptions(options);
+ OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+
+ MessageContext mc = new MessageContext();
+
+ System.out.println("Sending file : " + fileName + " as SwA");
+ FileDataSource fileDataSource = new FileDataSource(new File(fileName));
+ DataHandler dataHandler = new DataHandler(fileDataSource);
+ String attachmentID = mc.addAttachment(dataHandler);
+
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ SOAPEnvelope env = factory.getDefaultEnvelope();
+ OMNamespace ns = factory.createOMNamespace("http://www.apache-synapse.org/test", "m0");
+ OMElement payload = factory.createOMElement("uploadFileUsingSwA", ns);
+ OMElement request = factory.createOMElement("request", ns);
+ OMElement imageId = factory.createOMElement("imageId", ns);
+ imageId.setText(attachmentID);
+ request.addChild(imageId);
+ payload.addChild(request);
+ env.getBody().addChild(payload);
+ mc.setEnvelope(env);
+
+ mepClient.addMessageContext(mc);
+ mepClient.execute(true);
+ MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+
+ SOAPBody body = response.getEnvelope().getBody();
+ String imageContentId = body.
+ getFirstChildWithName(new QName("http://www.apache-synapse.org/test", "uploadFileUsingSwAResponse")).
+ getFirstChildWithName(new QName("http://www.apache-synapse.org/test", "response")).
+ getFirstChildWithName(new QName("http://www.apache-synapse.org/test", "imageId")).
+ getText();
+
+ Attachments attachment = response.getAttachmentMap();
+ dataHandler = attachment.getDataHandler(imageContentId);
+ File tempFile = File.createTempFile("swa-", ".gif");
+ FileOutputStream fos = new FileOutputStream(tempFile);
+ dataHandler.writeTo(fos);
+ fos.flush();
+ fos.close();
+
+ System.out.println("Saved response to file : " + tempFile.getAbsolutePath());
+ }
+
+ private static void sendUsingMTOM(String fileName, String targetEPR) throws IOException {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMNamespace ns = factory.createOMNamespace("http://www.apache-synapse.org/test", "m0");
+ OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns);
+ OMElement request = factory.createOMElement("request", ns);
+ OMElement image = factory.createOMElement("image", ns);
+
+ System.out.println("Sending file : " + fileName + " as MTOM");
+ FileDataSource fileDataSource = new FileDataSource(new File(fileName));
+ DataHandler dataHandler = new DataHandler(fileDataSource);
+ OMText textData = factory.createOMText(dataHandler, true);
+ image.addChild(textData);
+ request.addChild(image);
+ payload.addChild(request);
+
+ ServiceClient serviceClient = new ServiceClient();
+ Options options = new Options();
+ options.setTo(new EndpointReference(targetEPR));
+ options.setAction("urn:uploadFileUsingMTOM");
+ options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+
+ serviceClient.setOptions(options);
+ OMElement response = serviceClient.sendReceive(payload);
+
+ OMText binaryNode = (OMText) response.
+ getFirstChildWithName(new QName("http://www.apache-synapse.org/test", "response")).
+ getFirstChildWithName(new QName("http://www.apache-synapse.org/test", "image")).
+ getFirstOMChild();
+ dataHandler = (DataHandler) binaryNode.getDataHandler();
+ InputStream is = dataHandler.getInputStream();
+
+ File tempFile = File.createTempFile("mtom-", ".gif");
+ FileOutputStream fos = new FileOutputStream(tempFile);
+ BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);
+
+ byte data[] = new byte[BUFFER];
+ int count;
+ while ((count = is.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, count);
+ }
+
+ dest.flush();
+ dest.close();
+ System.out.println("Saved response to file : " + tempFile.getAbsolutePath());
+ }
+}
Modified: webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/StockQuoteClient.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/StockQuoteClient.java?view=diff&rev=530689&r1=530688&r2=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/StockQuoteClient.java (original)
+++ webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/StockQuoteClient.java Fri Apr 20 01:20:43 2007
@@ -22,6 +22,8 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axis2.Constants;
+import org.apache.axis2.transport.http.HttpTransportProperties;
+import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
@@ -32,46 +34,46 @@
import org.apache.neethi.Policy;
import samples.common.StockQuoteHandler;
-import javax.xml.namespace.QName;
+import java.net.URL;
/**
- * The EPR to the actual service is set, but the transport is set to
- * the Synapse url.
+ * ant stockquote
+ * [-Dsymbol=<sym>] [-Drepository=<repo>] [-Dpolicy=<policy>]
+ * [-Dmode=quote | customquote | fullquote | placeorder | marketactivity]
+ * [-Daddressingurl=<url>] [-Dtransporturl=<url> | -Dproxyurl=<url>]
+ *
+ * StockQuoteClient <symbol> <quote | customquote | fullquote | placeorder | marketactivity>
+ * <addurl> <trpurl> <prxurl> <repo> <policy>
*/
public class StockQuoteClient {
public static void main(String[] args) {
- String symbol = "IBM";
- String xurl = "http://localhost:9000/axis2/services/SimpleStockQuoteService";
- String turl = "http://localhost:8080";
- String sAction = "urn:getQuote";
- String repo = "client_repo";
- String secpol = null;
-
- if (args.length > 0) symbol = args[0];
- if (args.length > 1) xurl = args[1];
- if (args.length > 2) turl = args[2];
- if (args.length > 3) repo = args[3];
- if (args.length > 4) secpol = args[4];
+ // defaults
+ String symbol = "IBM";
+ String mode = "quote";
+ String addUrl = "http://localhost:9000/axis2/services/SimpleStockQuoteService";
+ String trpUrl = "http://localhost:8080";
+ String prxUrl = null;
+ String repo = "client_repo";
+ String svcPolicy = null;
+
+ if (args.length > 0) symbol = args[0];
+ if (args.length > 1) mode = args[1];
+ if (args.length > 2) addUrl = args[2];
+ if (args.length > 3) trpUrl = args[3];
+ if (args.length > 4) prxUrl = args[4];
+ if (args.length > 5) repo = args[5];
+ if (args.length > 6) svcPolicy = args[6];
- try {
- OMElement getQuote = StockQuoteHandler.createStandardRequestPayload(symbol);
+ double price = 0; int quantity = 0;
+ try {
Options options = new Options();
- if (xurl != null)
- options.setTo(new EndpointReference(xurl));
- if (turl != null)
- options.setProperty(Constants.Configuration.TRANSPORT_URL, turl);
- options.setAction(sAction);
-
- if (secpol != null && secpol.length() > 0) {
- options.setProperty(
- RampartMessageData.KEY_RAMPART_POLICY, loadPolicy(secpol));
- }
-
+ OMElement payload = null;
ServiceClient serviceClient = null;
- if (repo != null) {
+
+ if (repo != null && !"null".equals(repo)) {
ConfigurationContext configContext =
ConfigurationContextFactory.
createConfigurationContextFromFileSystem(repo, null);
@@ -79,16 +81,79 @@
} else {
serviceClient = new ServiceClient();
}
- serviceClient.engageModule("addressing");
- if (secpol != null && secpol.length() > 0) {
+
+ if ("customquote".equals(mode)) {
+ payload = StockQuoteHandler.createCustomQuoteRequest(symbol);
+ options.setAction("urn:getQuote");
+ } else if ("fullquote".equals(mode)) {
+ payload = StockQuoteHandler.createFullQuoteRequest(symbol);
+ options.setAction("urn:getFullQuote");
+ } else if ("placeorder".equals(mode)) {
+ price = getRandom(100, 0.9, true);
+ quantity = (int) getRandom(10000, 1.0, true);
+ payload = StockQuoteHandler.createPlaceOrderRequest(price, quantity, symbol);
+ options.setAction("urn:placeOrder");
+ } else if ("marketactivity".equals(mode)) {
+ payload = StockQuoteHandler.createMarketActivityRequest();
+ options.setAction("urn:getMarketActivity");
+ } else if ("quote".equals(mode)) {
+ payload = StockQuoteHandler.createStandardQuoteRequest(symbol);
+ options.setAction("urn:getQuote");
+ }
+
+ // set addressing, transport and proxy url
+ if (addUrl != null && !"null".equals(addUrl)) {
+ serviceClient.engageModule("addressing");
+ options.setTo(new EndpointReference(addUrl));
+ }
+ if (trpUrl != null && !"null".equals(trpUrl)) {
+ options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
+ }
+ if (prxUrl != null && !"null".equals(prxUrl)) {
+ HttpTransportProperties.ProxyProperties proxyProperties =
+ new HttpTransportProperties.ProxyProperties();
+ URL url = new URL(prxUrl);
+ proxyProperties.setProxyName(url.getHost());
+ proxyProperties.setProxyPort(url.getPort());
+ proxyProperties.setUserName("");
+ proxyProperties.setPassWord("");
+ proxyProperties.setDomain("");
+ options.setProperty(HTTPConstants.PROXY, proxyProperties);
+ }
+
+ // apply any service policies if any
+ if (svcPolicy != null && !"null".equals(svcPolicy) && svcPolicy.length() > 0) {
+ serviceClient.engageModule("addressing");
serviceClient.engageModule("rampart");
+ options.setProperty(
+ RampartMessageData.KEY_RAMPART_POLICY, loadPolicy(svcPolicy));
}
+
serviceClient.setOptions(options);
- OMElement result = serviceClient.sendReceive(getQuote).getFirstElement();
- System.out.println("Standard :: Stock price = $" +
- StockQuoteHandler.parseStandardResponsePayload(result));
+ if ("placeorder".equals(mode)) {
+ serviceClient.fireAndForget(payload);
+ Thread.sleep(5000);
+ System.out.println("Order placed for " + quantity + " shares of stock " +
+ symbol + " at a price of $ " + price);
+
+ } else {
+ OMElement result = serviceClient.sendReceive(payload);
+ if("customquote".equals(mode)) {
+ System.out.println("Custom :: Stock price = $" +
+ StockQuoteHandler.parseCustomQuoteResponse(result));
+ } else if ("quote".equals(mode)) {
+ System.out.println("Standard :: Stock price = $" +
+ StockQuoteHandler.parseStandardQuoteResponse(result));
+ } else if ("fullquote".equals(mode)) {
+ System.out.println("Full :: Average price = $" +
+ StockQuoteHandler.parseFullQuoteResponse(result));
+ } else if ("marketactivity".equals(mode)) {
+ System.out.println("Activity :: Average price = $" +
+ StockQuoteHandler.parseMarketActivityResponse(result));
+ }
+ }
} catch (Exception e) {
e.printStackTrace();
@@ -98,6 +163,12 @@
private static Policy loadPolicy(String xmlPath) throws Exception {
StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
return PolicyEngine.getPolicy(builder.getDocumentElement());
+ }
+
+ private static double getRandom(double base, double varience, boolean onlypositive) {
+ double rand = Math.random();
+ return (base + ((rand > 0.5 ? 1 : -1) * varience * base * rand))
+ * (onlypositive ? 1 : (rand > 0.5 ? 1 : -1));
}
}
Modified: webservices/synapse/trunk/java/modules/samples/src/main/java/samples/util/SampleAxis2Server.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/src/main/java/samples/util/SampleAxis2Server.java?view=diff&rev=530689&r1=530688&r2=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/src/main/java/samples/util/SampleAxis2Server.java (original)
+++ webservices/synapse/trunk/java/modules/samples/src/main/java/samples/util/SampleAxis2Server.java Fri Apr 20 01:20:43 2007
@@ -42,7 +42,7 @@
int port = -1;
- public static int DEFAULT_PORT = 8080;
+ public static int DEFAULT_PORT = 9000;
/**
@@ -85,13 +85,13 @@
log.info("[SimpleAxisServer] Starting");
if (repoOption != null) {
repoLocation = repoOption.getOptionValue();
- System.out.println("[SimpleAxisServer] Using the Axis2 Repository"
+ System.out.println("[SimpleAxisServer] Using the Axis2 Repository : "
+ new File(repoLocation).getAbsolutePath());
}
if (confOption != null) {
confLocation = confOption.getOptionValue();
System.out
- .println("[SimpleAxisServer] Using the Axis2 Configuration File"
+ .println("[SimpleAxisServer] Using the Axis2 Configuration File : "
+ new File(confLocation).getAbsolutePath());
}
@@ -123,11 +123,11 @@
new Integer(port);
trsIn.getParameter("port").setValue(port);
} catch (NumberFormatException e) {
- log.error("Given port is not a valid integer. Using 9001 for port.");
- trsIn.getParameter("port").setValue("9001");
+ log.error("Given port is not a valid integer. Using 9000 for port.");
+ trsIn.getParameter("port").setValue("9000");
}
} else {
- trsIn.getParameter("port").setValue("9001");
+ trsIn.getParameter("port").setValue("9000");
}
}
Modified: webservices/synapse/trunk/java/modules/samples/src/main/scripts/build.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/src/main/scripts/build.xml?view=diff&rev=530689&r1=530688&r2=530689
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/src/main/scripts/build.xml (original)
+++ webservices/synapse/trunk/java/modules/samples/src/main/scripts/build.xml Fri Apr 20 01:20:43 2007
@@ -19,90 +19,62 @@
<project name="samples" default="help" basedir=".">
<target name="help">
- <echo>
- This script requires Ant 1.5 or higher
-
- usage:
- ant -help
- display ant help screen
- ant help
- display this message
- ant clean
- delete the build directory
- ant compile
- build the samples
-
- These client samples are able to send stock quote and order placement messages
-
- ant stockquote
- This client could be used to act as a 'smart client', by specifying a
- WS-Addressing EPR directed to the real endpoint, and the transport endpoint
- set differently
-
- examples:
- ant stockquote
- ant stockquote [-Dsymbol=IBM]
- [-Durl=http://localhost:9000/axis2/services/SimpleStockQuoteService]
- [-Dtransporturl=http://localhost:8080] [-Drepository=client_repo]
- [-Dsecpolicy=..\..\repository\conf\sample\resources\policy\policy_1.xml]
-
- ant proxystockquote
- A client that could act as a HTTP proxy client
-
- examples:
- ant proxystockquote
- ant proxystockquote [-Dsymbol=IBM]
- [-Durl=http://localhost:9000/axis2/services/SimpleStockQuoteService]
- [-Dtransporturl=http://localhost:8080]
-
- ant dumbstockquote
- A client that could directly invoke the service on a given endpoint. i.e. as a 'gateway'
-
- examples:
- ant dumbstockquote
- ant dumbstockquote [-Dsymbol=IBM]
- [-Dgatewayurl=http://localhost:8080/axis2/services/StockQuoteProxy]
- [-Dsecpolicy=..\..\repository\conf\sample\resources\policy\policy_1.xml]
-
- ant customquote
- A client which could send out a stock quote request in a custom format. It is
- expected to transform this message to a standard request, and the response back as
- a custom response as expected by this client
-
- examples:
- ant customquote
- ant customquote [-Dsymbol=IBM]
- [-Durl=http://localhost:9000/axis2/services/SimpleStockQuoteService]
- [-Dtransporturl=http://localhost:8080]
-
- ant placeorder
- A client which could send out a one way message using the Axis2 ServiceClient's
- fireAndForget() API
-
- examples:
- ant placeorder
- ant placeorder
- [-Dsymbol=IBM] [-Dgatewayurl=http://localhost:8080/axis2/services/StockQuoteProxy]
-
- ant jmsclient
- A client which could post a JMS text or binary message to a given destination.
-
- examples
- ant jmsclient
- [-Ddest=dynamicQueues/JMSTextProxy] [-Dtype=text|binary|xml]
- [-Dpayload="24.34 100 IBM | MSFT" | "repository\conf\sample\resources\mtom\asf-logo.gif"]
- </echo>
+ <echo>
+ ant stockquote
+ Creates and sends a stock quote request. Could execute in 'smart client', 'proxy' and
+ 'gateway' modes by specifying WSA, transport and HTTP proxy endpoints/URLs. Optionally
+ a policy (security) could be applied to the requests. The required stock symbol and
+ operation could be specified as follows:
+
+ examples:
+ ant stockquote
+
+ ant stockquote [-Dsymbol=IBM|MSFT|SUN|..]
+ [-Dmode=quote | customquote | fullquote | placeorder | marketactivity]
+ [-Daddurl=http://localhost:9000/axis2/services/SimpleStockQuoteService]
+ [-Dtrourl=http://localhost:8080] [-Dprxurl=http://localhost:8080]
+ [-Drepository=client_repo]
+ [-Dpolicy=../../repository/conf/sample/resources/policy/policy_1.xml]
+
+ Mode :
+ quote - send a quote request for a single stock
+ customquote - send a quote request in a custom format
+ fullquote - get quote reports for a period (i.e. 365 days of the year)
+ placeorder - place an order for stocks using a one way request
+ marketactivity - get a market activity report (i.e. quotes for multiple symbols)
+
+ ant jmsclient
+ A client which could post a raw JMS text or binary message to a given destination.
+
+ examples:
+ ant jmsclient [-Djms_payload="24.34 100 IBM"]
+ ant jmsclient [-Djms_type=pox] [-Djms_dest=dynamicQueues/JMSPoxProxy] [-Djms_payload=MSFT]
+ ant jmsclient [-Djms_type=binary] [-Djms_dest=dynamicQueues/JMSFileUploadProxy]
+ [-Djms_payload=./../../repository/conf/sample/resources/mtom/asf-logo.gif]
+
+ ant optimizeclient
+ A client that could send binary content using MTOM and SwA optimizations
+
+ examples:
+ ant optimizeclient [-Dopt_mode=mtom | swa]
+ [-Dopt_url=http://localhost:8080/axis2/services/MTOMSwASampleService]
+ [-Dopt_file=./../../repository/conf/sample/resources/mtom/asf-logo.gif]
+ </echo>
</target>
<property name="symbol" value="IBM"/>
- <property name="url" value="http://localhost:9000/axis2/services/SimpleStockQuoteService"/>
- <property name="transporturl" value="http://localhost:8080"/>
- <property name="gatewayurl" value="http://localhost:8080/StockQuote"/>
+ <property name="mode" value="quote"/>
+ <property name="addurl" value="http://localhost:9000/axis2/services/SimpleStockQuoteService"/>
+ <property name="trpurl" value="http://localhost:8080"/>
+ <property name="prxurl" value="http://localhost:8080/StockQuote"/>
<property name="repository" value="client_repo"/>
- <property name="secpolicy" value=""/>
- <property name="dest" value="dynamicQueues/JMSTextProxy"/>
- <property name="type" value="text"/> <!-- or "binary" -->
- <property name="payload" value=""/>
+ <property name="policy" value=""/>
+ <property name="jms_dest" value="dynamicQueues/JMSTextProxy"/>
+ <property name="jms_type" value="text"/>
+ <property name="jms_payload" value=""/>
+ <property name="opt_mode" value="mtom"/>
+ <property name="opt_url" value="http://localhost:8080/axis2/services/MTOMSwASampleService"/>
+ <property name="opt_file" value="./../../repository/conf/sample/resources/mtom/asf-logo.gif"/>
<property name="class.dir" value="target/classes"/>
@@ -121,46 +93,30 @@
<java classname="samples.userguide.StockQuoteClient"
classpathref="javac.classpath" fork="true">
<arg value="${symbol}"/>
- <arg value="${url}"/>
- <arg value="${transporturl}"/>
- <arg value="${repository}"/>
- <arg value="${secpolicy}"/>
- </java>
- </target>
-
- <target name="proxystockquote" depends="compile">
- <java classname="samples.userguide.ProxyStockQuoteClient"
- classpathref="javac.classpath" fork="true">
- <arg value="${symbol}"/>
- <arg value="${url}"/>
- <arg value="${transporturl}"/>
- </java>
- </target>
-
- <target name="dumbstockquote" depends="compile">
- <java classname="samples.userguide.DumbStockQuoteClient"
- classpathref="javac.classpath" fork="true">
- <arg value="${symbol}"/>
- <arg value="${gatewayurl}"/>
+ <arg value="${mode}"/>
+ <arg value="${addurl}"/>
+ <arg value="${trpurl}"/>
+ <arg value="${prxurl}"/>
<arg value="${repository}"/>
- <arg value="${secpolicy}"/>
+ <arg value="${policy}"/>
</java>
</target>
- <target name="customquote" depends="compile">
- <java classname="samples.userguide.CustomStockQuoteClient"
+ <target name="jmsclient" depends="compile">
+ <java classname="samples.userguide.GenericJMSClient"
classpathref="javac.classpath" fork="true">
- <arg value="${symbol}"/>
- <arg value="${url}"/>
- <arg value="${transporturl}"/>
+ <arg value="${jms_dest}"/>
+ <arg value="${jms_type}"/>
+ <arg value="${jms_payload}"/>
</java>
</target>
- <target name="placeorder" depends="compile">
- <java classname="samples.userguide.PlaceOrderClient"
+ <target name="optimizeclient" depends="compile">
+ <java classname="samples.userguide.MTOMSwAClient"
classpathref="javac.classpath" fork="true">
- <arg value="${symbol}"/>
- <arg value="${gatewayurl}"/>
+ <arg value="${opt_mode}"/>
+ <arg value="${opt_url}"/>
+ <arg value="${opt_file}"/>
</java>
</target>
@@ -183,15 +139,6 @@
<sysproperty key="msg" value="${msg}"/>
<sysproperty key="t" value="${t}"/>
<sysproperty key="session" value="${session}"/>
- </java>
- </target>
-
- <target name="jmsclient" depends="compile">
- <java classname="samples.userguide.GenericJMSClient"
- classpathref="javac.classpath" fork="true">
- <arg value="${dest}"/>
- <arg value="${type}"/>
- <arg value="${payload}"/>
</java>
</target>
Modified: webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_105.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_105.xml?view=diff&rev=530689&r1=530688&r2=530689
==============================================================================
--- webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_105.xml (original)
+++ webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_105.xml Fri Apr 20 01:20:43 2007
@@ -17,66 +17,61 @@
~ under the License.
-->
-<synapse xmlns="http://ws.apache.org/ns/synapse">
+<definitions xmlns="http://ws.apache.org/ns/synapse">
<!-- demonstrate JMS raw Text / POX message support -->
- <definitions>
- <sequence name="text_proxy">
- <header name="Action" value="urn:placeOrder"/>
- <script.js><![CDATA[
- var args = mc.getPayloadXML().toString().split(" ");
- mc.setPayloadXML(
- <m:placeOrder xmlns:m="http://services.samples/xsd">
- <m:order>
- <m:price>{args[0]}</m:price>
- <m:quantity>{args[1]}</m:quantity>
- <m:symbol>{args[2]}</m:symbol>
- </m:order>
- </m:placeOrder>);
- ]]></script.js>
- <send>
- <endpoint>
- <address uri="http://localhost:9000/axis2/services/SimpleStockQuoteService"/>
- </endpoint>
- </send>
- </sequence>
-
- <sequence name="mtom_proxy">
- <header name="Action" value="urn:uploadFileUsingMTOM"/>
- <send>
- <endpoint>
- <address uri="http://localhost:9000/axis2/services/MTOMSampleService" optimize="mtom"/>
- </endpoint>
- </send>
- </sequence>
-
- <sequence name="pox_proxy">
- <header name="Action" value="urn:placeOrder"/>
- <send>
- <endpoint>
- <address uri="http://localhost:9000/axis2/services/SimpleStockQuoteService" force="soap"/>
- </endpoint>
- </send>
- </sequence>
- </definitions>
-
- <proxies>
- <proxy name="JMSFileUploadProxy" transports="jms">
- <target inSequence="mtom_proxy"/>
- <parameter name="transport.jms.Wrapper">{http://services.samples/xsd}element</parameter>
- </proxy>
- <proxy name="JMSTextProxy" transports="jms">
- <target inSequence="text_proxy"/>
- <parameter name="transport.jms.Wrapper">{http://services.samples/xsd}text</parameter>
- </proxy>
- <proxy name="JMSPoxProxy" transports="jms">
- <target inSequence="pox_proxy"/>
- </proxy>
- </proxies>
-
- <rules>
- <log level="full"/>
- <drop/>
- </rules>
+ <sequence name="text_proxy">
+ <header name="Action" value="urn:placeOrder"/>
+ <script language="js"><![CDATA[
+ var args = mc.getPayloadXML().toString().split(" ");
+ mc.setPayloadXML(
+ <m:placeOrder xmlns:m="http://services.samples/xsd">
+ <m:order>
+ <m:price>{args[0]}</m:price>
+ <m:quantity>{args[1]}</m:quantity>
+ <m:symbol>{args[2]}</m:symbol>
+ </m:order>
+ </m:placeOrder>);
+ ]]></script>
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9000/axis2/services/SimpleStockQuoteService"/>
+ </endpoint>
+ </send>
+ </sequence>
+
+ <sequence name="mtom_proxy">
+ <header name="Action" value="urn:oneWayUploadUsingMTOM"/>
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9000/axis2/services/MTOMSwASampleService" optimize="mtom"/>
+ </endpoint>
+ </send>
+ </sequence>
+
+ <sequence name="pox_proxy">
+ <header name="Action" value="urn:placeOrder"/>
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9000/axis2/services/SimpleStockQuoteService" force="soap"/>
+ </endpoint>
+ </send>
+ </sequence>
+
+ <sequence name="out">
+ <send/>
+ </sequence>
+
+ <proxy name="JMSFileUploadProxy" transports="jms">
+ <target inSequence="mtom_proxy" outSequence="out"/>
+ <parameter name="transport.jms.Wrapper">{http://services.samples/xsd}element</parameter>
+ </proxy>
+ <proxy name="JMSTextProxy" transports="jms">
+ <target inSequence="text_proxy" outSequence="out"/>
+ <parameter name="transport.jms.Wrapper">{http://services.samples/xsd}text</parameter>
+ </proxy>
+ <proxy name="JMSPoxProxy" transports="jms">
+ <target inSequence="pox_proxy" outSequence="out"/>
+ </proxy>
-</synapse>
\ No newline at end of file
+</definitions>
\ No newline at end of file
Added: webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_12.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_12.xml?view=auto&rev=530689
==============================================================================
--- webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_12.xml (added)
+++ webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_12.xml Fri Apr 20 01:20:43 2007
@@ -0,0 +1,48 @@
+<!--
+ ~ 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">
+ <in>
+ <filter source="get-property('Action')" regex="urn:uploadFileUsingMTOM">
+ <property name="example" value="mtom"/>
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9001/axis2/services/MTOMSwASampleService" optimize="mtom"/>
+ </endpoint>
+ </send>
+ </filter>
+ <filter source="get-property('Action')" regex="urn:uploadFileUsingSwA">
+ <property name="example" value="swa"/>
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9001/axis2/services/MTOMSwASampleService" optimize="swa"/>
+ </endpoint>
+ </send>
+ </filter>
+ </in>
+ <out>
+ <filter source="get-property('example')" regex="mtom">
+ <property name="enableMTOM" value="true" scope="axis2"/>
+ </filter>
+ <filter source="get-property('example')" regex="swa">
+ <property name="enableSwA" value="true" scope="axis2"/>
+ </filter>
+ <send/>
+ </out>
+</definitions>
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org