You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by gm...@apache.org on 2012/08/15 01:51:26 UTC
svn commit: r1373166 - in
/cxf/trunk/distribution/src/main/release/samples/wsdl_first: README.txt
pom.xml src/main/resources/CustomerService.wsdl
src/main/webapp/WEB-INF/web.xml
Author: gmazza
Date: Tue Aug 14 23:51:26 2012
New Revision: 1373166
URL: http://svn.apache.org/viewvc?rev=1373166&view=rev
Log:
Simplified example: included web.xml, removed need to place CXF version in endpoint URL string
Added:
cxf/trunk/distribution/src/main/release/samples/wsdl_first/src/main/webapp/WEB-INF/web.xml
Modified:
cxf/trunk/distribution/src/main/release/samples/wsdl_first/README.txt
cxf/trunk/distribution/src/main/release/samples/wsdl_first/pom.xml
cxf/trunk/distribution/src/main/release/samples/wsdl_first/src/main/resources/CustomerService.wsdl
Modified: cxf/trunk/distribution/src/main/release/samples/wsdl_first/README.txt
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/wsdl_first/README.txt?rev=1373166&r1=1373165&r2=1373166&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/wsdl_first/README.txt (original)
+++ cxf/trunk/distribution/src/main/release/samples/wsdl_first/README.txt Tue Aug 14 23:51:26 2012
@@ -2,10 +2,10 @@ WSDL First Demo
===============
This demo shows how to build and call a webservice using a given WSDL (also called Contract First).
-As writing a WSDL by hand is not so easy the following Howto may also be a useful read:
+As writing a WSDL by hand is not so easy the following How-To may be a useful read:
http://cxf.apache.org/docs/defining-contract-first-webservices-with-wsdl-generation-from-java.html
-This demo mainly addresses SOAP over HTTP in Document / Literal or Document / Literal wrapped style.
+This demo mainly addresses SOAP over HTTP in Document/Literal or Document/Literal wrapped style.
For other transports or styles the configuration may look different.
The Demo consist of three parts:
@@ -16,12 +16,12 @@ The Demo consist of three parts:
Code generation
---------------
-When using maven the code generation is done using the maven cxf-codegen-plugin
-(see http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html).
+When using Maven the code generation is done using the Maven cxf-codegen-plugin
+(http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html).
-The code generation is tuned using a binding.xml file. In this case the file configures that
-normal java Date is used for xsd:date and xsd:DateTime. If this is not present then XMLGregorianCalendar
-will be used.
+The code generation is tuned using a binding.xml file. In this case the file configures
+normal Java Dates to be used for xsd:date and xsd:DateTime. If this is not present then
+XMLGregorianCalendar will be used.
One other common use of the binding file is to also generate asynchronous stubs. The line
jaxws:enableAsyncMapping has to be uncommented to use this.
@@ -32,31 +32,36 @@ http://jax-ws.java.net/jax-ws-20-fcs/doc
Server implementation
---------------------
-The service is implemented in the class CustomerServiceImpl. The class simply implements the previously
-generated service interface. The method getCustomersByName demonstrates how a query function could look like.
-The idea is to search and return all customers with the given name. If the searched name is none then the method
-returns an exception to indicate that no matching customer was found. (In a real implementation probably a list with
-zero objects would be used. This is mainly to show how custom exceptions can be used).
-For any other name the method will return a list of two Customer objects. The number of objects can be increased to
-test how fast CXF works for larger data.
-
-Now that the service is implemented it needs to be made available. This samples provides two options for deploying the
-web service provider: standalone server (using embedded Jetty) or as a WAR file in Tomcat (Version 6.x or 7.x).
+The service is implemented in the class CustomerServiceImpl. The class simply implements
+the previously generated service interface. The method getCustomersByName demonstrates
+what a query function could look like. The idea is to search and return all customers
+with a given name. If the searched name is none then the method returns an exception
+to indicate that no matching customer was found. (In a real implementation a list with
+zero objects would probably be used. This is mainly to show how custom exceptions can be
+created). For any other name the method will return a list of two Customer objects. The
+number of objects can be increased to test how fast CXF works for larger data.
+
+Now that the service is implemented it needs to be made available. This sample provides
+two options for deploying the web service provider: standalone server (using embedded
+Jetty) or as a WAR file in Tomcat (Version 6.x or 7.x).
Client implementation
---------------------
-The main client code lives in the class CustomerServiceTester. This class needs a proxy to the service and then
-demonstrates some calls and their expected outcome using junit assertions.
-
-The first call is a request getCustomersByName for all customers with name "Smith". The result is then checked.
-Then the same method is called with the invalid name "None". In this case a NoSuchCustomerException is expected.
-The third call shows that the one way method updateCustomer will return instantly even if the service needs some
-time to process the request.
-
-The classes CustomerServiceClient and CustomerServiceSpringClient show how to get a service proxy using JAX-WS
-or Spring and how to wire it to your business class (in this case CustomerServiceTester).
+The main client code lives in the class CustomerServiceTester. This class needs a proxy
+to the service and then demonstrates some calls and their expected outcome using junit
+assertions.
+
+The first call is a request getCustomersByName for all customers with name "Smith".
+The result is then checked. Then the same method is called with the invalid name "None".
+In this case a NoSuchCustomerException is expected. The third call shows that the one
+way method updateCustomer will return instantly even if the service needs some time to
+process the request.
+
+The classes CustomerServiceClient and CustomerServiceSpringClient show how to get a
+service proxy using JAX-WS or Spring and how to wire it to your business class
+(in this case CustomerServiceTester).
Prerequisite
------------
@@ -64,7 +69,6 @@ Please review the README in the samples
Building and running the demo using Maven
-----------------------------------------
-
From the base directory of this sample (i.e., where this README file is
located), the pom.xml file is used to build and run the demo.
@@ -74,30 +78,32 @@ Using either UNIX or Windows:
mvn -Pserver (from one command line window -- only if using a standalone service, i.e., embedded Jetty)
mvn -Pclient (from a second command line window)
+
If you're using Tomcat for the web service provider:
----------------------------------------------------
1.) Update the soap:address value in the resources/CustomerService.wsdl value, switching the
-soap:address value to the servlet-specific one (presently commented-out). Make sure the version
-number there is the same as the version of CXF being used.
+soap:address value to the servlet-specific one (presently commented-out).
2.) You can manually copy the generated WAR file to the Tomcat webapps folder, or, if you
-have Maven and Tomcat set up to use the Tomcat Maven Plugin (http://mojo.codehaus.org/tomcat-maven-plugin/)
-you can use the mvn tomcat:redeploy command instead. Important: if you're using this
-command, and are using Tomcat 6 instead of Tomcat 7, update the tomcat-maven-plugin configuration
-in the pom.xml, switching to the the Tomcat 6-specific "url" element.
+have Maven and Tomcat set up to use the Tomcat Maven Plugin
+(http://mojo.codehaus.org/tomcat-maven-plugin/) you can use the mvn tomcat:redeploy
+command instead. Important: if you're using this command, and are using Tomcat 6
+instead of Tomcat 7, update the tomcat-maven-plugin configuration in the pom.xml,
+switching to the the Tomcat 6-specific "url" element.
To remove the code generated from the WSDL file and the .class files, run "mvn clean".
-There is no special maven profile for the spring client and server but you can easily set it up yourself.
+There is no special Maven profile for the spring client and server but you can easily
+set it up yourself.
Using Eclipse to run and test the demo
--------------------------------------
-
-run the following in the demo base directory
+Run the following in the demo base directory
mvn eclipse:eclipse
-Then use Import / Existing projects into workspace and browse to the wsdl_first directory. Import the wsdl_first project.
+Then use Import / Existing projects into workspace and browse to the wsdl_first directory.
+Import the wsdl_first project.
The demo can now be started using "Run as Java Application" on the CustomerServiceServer.java
and the CustomerServiceClient. For the spring demo run the classes CustomerServiceSpringClient.java
Modified: cxf/trunk/distribution/src/main/release/samples/wsdl_first/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/wsdl_first/pom.xml?rev=1373166&r1=1373165&r2=1373166&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/wsdl_first/pom.xml (original)
+++ cxf/trunk/distribution/src/main/release/samples/wsdl_first/pom.xml Tue Aug 14 23:51:26 2012
@@ -43,7 +43,7 @@
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
- <webXml>${cxf.release.base}/etc/web.xml</webXml>
+ <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
<webResources>
<resource>
<directory>src/main/resources</directory>
@@ -103,6 +103,7 @@
</executions>
</plugin>
</plugins>
+ <finalName>wsdl_first</finalName>
</build>
<profiles>
<profile>
Modified: cxf/trunk/distribution/src/main/release/samples/wsdl_first/src/main/resources/CustomerService.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/wsdl_first/src/main/resources/CustomerService.wsdl?rev=1373166&r1=1373165&r2=1373166&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/wsdl_first/src/main/resources/CustomerService.wsdl (original)
+++ cxf/trunk/distribution/src/main/release/samples/wsdl_first/src/main/resources/CustomerService.wsdl Tue Aug 14 23:51:26 2012
@@ -120,7 +120,7 @@
<!-- embedded deployment -->
<soap:address location="http://localhost:9090/CustomerServicePort"/>
<!-- standalone Tomcat deployment -->
- <!--soap:address location="http://localhost:8080/wsdl_first-<cxf-version>/services/CustomerServicePort"/-->
+ <!--soap:address location="http://localhost:8080/wsdl_first/services/CustomerServicePort"/-->
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Added: cxf/trunk/distribution/src/main/release/samples/wsdl_first/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/wsdl_first/src/main/webapp/WEB-INF/web.xml?rev=1373166&view=auto
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/wsdl_first/src/main/webapp/WEB-INF/web.xml (added)
+++ cxf/trunk/distribution/src/main/release/samples/wsdl_first/src/main/webapp/WEB-INF/web.xml Tue Aug 14 23:51:26 2012
@@ -0,0 +1,44 @@
+<?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.
+-->
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>cxf</display-name>
+
+ <servlet>
+ <servlet-name>cxf</servlet-name>
+ <display-name>cxf</display-name>
+ <description>Apache CXF Endpoint</description>
+ <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>cxf</servlet-name>
+ <url-pattern>/services/*</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>60</session-timeout>
+ </session-config>
+
+</web-app>
+