Author: sagara Date: Mon Mar 19 05:59:31 2012 New Revision: 1302280 URL: http://svn.apache.org/viewvc?rev=1302280&view=rev Log: AXIS2-4253 - Added WSDL 1.1 and WSDL 2.0 based dynamic client sample.
Added: axis/axis2/java/core/trunk/modules/samples/dynamicclient/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/README.txt (with props) axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/pom.xml (with props) axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL11DynamicClient.java (with props) axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL20DynamicClient.java (with props) axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/resources/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/test/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/test/java/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/test/resources/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/pom.xml (with props) axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/pom.xml (with props) axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/apache/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/apache/axis2/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/apache/axis2/examples/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/apache/axis2/examples/server/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/apache/axis2/examples/server/CalculatorService.java (with props) axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/resources/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/resources/services/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/resources/services/CalculatorService/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/resources/services/CalculatorService/META-INF/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/resources/services/CalculatorService/META-INF/services.xml (with props) axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/test/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/test/java/ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/test/resources/ Added: axis/axis2/java/core/trunk/modules/samples/dynamicclient/README.txt URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/dynamicclient/README.txt?rev=1302280&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/samples/dynamicclient/README.txt (added) +++ axis/axis2/java/core/trunk/modules/samples/dynamicclient/README.txt Mon Mar 19 05:59:31 2012 @@ -0,0 +1,18 @@ +Axis2 Dynamic client Sample +========================= + + +Building the Service +==================== +* Move to "server" directory +* Run "mvn axis2:run" this will start Axis2 Simple HTTP server with above service. + + + +Running the Clients +=================== + +* Run each clients using a IDE or use following Maven commands. + +mvn exec:java -Dexec.mainClass="org.apache.axis2.examples.client.WSDL11DynamicClient" -Dexec.classpathScope=compile +mvn exec:java -Dexec.mainClass="org.apache.axis2.examples.client.WSDL20DynamicClient" -Dexec.classpathScope=compile Propchange: axis/axis2/java/core/trunk/modules/samples/dynamicclient/README.txt ------------------------------------------------------------------------------ svn:eol-style = native Propchange: axis/axis2/java/core/trunk/modules/samples/dynamicclient/README.txt ------------------------------------------------------------------------------ svn:executable = * Added: axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/pom.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/pom.xml?rev=1302280&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/pom.xml (added) +++ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/pom.xml Mon Mar 19 05:59:31 2012 @@ -0,0 +1,51 @@ +<!-- + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>dynamic-client</artifactId> + <groupId>org.apache.axis2.examples</groupId> + <version>1.7.0-SNAPSHOT</version> + </parent> + <groupId>org.apache.axis2.examples</groupId> + <artifactId>client</artifactId> + <version>1.7.0-SNAPSHOT</version> + + <dependencies> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-adb</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-transport-http</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-transport-local</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> +</project> \ No newline at end of file Propchange: axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL11DynamicClient.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL11DynamicClient.java?rev=1302280&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL11DynamicClient.java (added) +++ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL11DynamicClient.java Mon Mar 19 05:59:31 2012 @@ -0,0 +1,65 @@ +/* + * 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 org.apache.axis2.examples.client; + +import java.net.MalformedURLException; +import java.net.URL; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.client.ServiceClient; + +public class WSDL11DynamicClient { + + public static void main(String[] args) throws MalformedURLException, AxisFault { + + URL wsdlURL = new URL("http://localhost:8080/axis2/services/CalculatorService?wsdl"); + QName serviceName = new QName("http://server.examples.axis2.apache.org", "CalculatorService"); + String port = "CalculatorServiceHttpEndpoint"; + ServiceClient serviceClient = new ServiceClient(null, wsdlURL, serviceName, port); + OMElement res = serviceClient.sendReceive(new QName( + "http://server.examples.axis2.apache.org", "add"), creatMsg()); + System.out.println(res); + + } + + public static OMElement creatMsg() { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://server.examples.axis2.apache.org", "ns1"); + // creating the payload + OMElement method = fac.createOMElement("add", omNs); + OMElement value1 = fac.createOMElement("value1", omNs); + OMElement value2 = fac.createOMElement("value2", omNs); + + value1.setText("4"); + value2.setText("3"); + + method.addChild(value1); + method.addChild(value2); + + return method; + } + +} Propchange: axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL11DynamicClient.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL20DynamicClient.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL20DynamicClient.java?rev=1302280&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL20DynamicClient.java (added) +++ axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL20DynamicClient.java Mon Mar 19 05:59:31 2012 @@ -0,0 +1,65 @@ +/* + * 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 org.apache.axis2.examples.client; + +import java.net.MalformedURLException; +import java.net.URL; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.client.ServiceClient; + +public class WSDL20DynamicClient { + + public static void main(String[] args) throws MalformedURLException, AxisFault { + + URL wsdlURL = new URL("http://localhost:8080/axis2/services/CalculatorService?wsdl2"); + QName serviceName = new QName("http://server.examples.axis2.apache.org", "CalculatorService"); + String port = "CalculatorServiceHttpEndpoint"; + ServiceClient serviceClient = new ServiceClient(null, wsdlURL, serviceName, port); + OMElement res = serviceClient.sendReceive(new QName( + "http://server.examples.axis2.apache.org", "add"), creatMsg()); + System.out.println(res); + + } + + public static OMElement creatMsg() { + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://server.examples.axis2.apache.org", "ns1"); + // creating the payload + OMElement method = fac.createOMElement("add", omNs); + OMElement value1 = fac.createOMElement("value1", omNs); + OMElement value2 = fac.createOMElement("value2", omNs); + + value1.setText("4"); + value2.setText("5"); + + method.addChild(value1); + method.addChild(value2); + + return method; + } + +} Propchange: axis/axis2/java/core/trunk/modules/samples/dynamicclient/client/src/main/java/org/apache/axis2/examples/client/WSDL20DynamicClient.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/trunk/modules/samples/dynamicclient/pom.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/dynamicclient/pom.xml?rev=1302280&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/samples/dynamicclient/pom.xml (added) +++ axis/axis2/java/core/trunk/modules/samples/dynamicclient/pom.xml Mon Mar 19 05:59:31 2012 @@ -0,0 +1,32 @@ +<!-- + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.axis2.examples</groupId> + <artifactId>dynamic-client</artifactId> + <version>1.7.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <modules> + <module>server</module> + <module>client</module> + </modules> + +</project> \ No newline at end of file Propchange: axis/axis2/java/core/trunk/modules/samples/dynamicclient/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/pom.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/pom.xml?rev=1302280&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/pom.xml (added) +++ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/pom.xml Mon Mar 19 05:59:31 2012 @@ -0,0 +1,88 @@ +<!-- + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>dynamic-client</artifactId> + <groupId>org.apache.axis2.examples</groupId> + <version>1.7.0-SNAPSHOT</version> + </parent> + <groupId>org.apache.axis2.examples</groupId> + <artifactId>server</artifactId> + <version>1.7.0-SNAPSHOT</version> + + <dependencies> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-adb</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-transport-http</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-transport-local</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + <build> + <plugins> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.axis2</groupId> + <artifactId>simple-server-maven-plugin</artifactId> + <version>${project.version}</version> + </plugin> + + <plugin> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-aar-maven-plugin</artifactId> + <version>${project.version}</version> + <configuration> + <servicesXmlFile>src/main/resources/services/CalculatorService/META-INF/services.xml</servicesXmlFile> + </configuration> + <executions> + <execution> + <id>generates aar</id> + <phase>package</phase> + <goals> + <goal>aar</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Propchange: axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/apache/axis2/examples/server/CalculatorService.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/apache/axis2/examples/server/CalculatorService.java?rev=1302280&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/apache/axis2/examples/server/CalculatorService.java (added) +++ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/apache/axis2/examples/server/CalculatorService.java Mon Mar 19 05:59:31 2012 @@ -0,0 +1,32 @@ +/* + * 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 org.apache.axis2.examples.server; + +public class CalculatorService { + + public int add(int value1, int value2) { + return value1 + value2; + } + + public int multiply(int value1, int value2) { + return value1 * value2; + } + +} Propchange: axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/java/org/apache/axis2/examples/server/CalculatorService.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/resources/services/CalculatorService/META-INF/services.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/resources/services/CalculatorService/META-INF/services.xml?rev=1302280&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/resources/services/CalculatorService/META-INF/services.xml (added) +++ axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/resources/services/CalculatorService/META-INF/services.xml Mon Mar 19 05:59:31 2012 @@ -0,0 +1,32 @@ +<?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. + --> + +<serviceGroup> + <service name="CalculatorService"> + <parameter name="ServiceClass">org.apache.axis2.examples.server.CalculatorService</parameter> + <operation name="add"> + <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> + </operation> + <operation name="multiply"> + <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> + </operation> + </service> +</serviceGroup> \ No newline at end of file Propchange: axis/axis2/java/core/trunk/modules/samples/dynamicclient/server/src/main/resources/services/CalculatorService/META-INF/services.xml ------------------------------------------------------------------------------ svn:eol-style = native