Axis2 JAX-WS sample that uses JAXB artifacts created from a simple schema.
1. Given a simple schema, generate the JAXB artifacts using xjc.
2. With the generated JAXB beans in hand, write the service implementation
and add annotations to make a Web Service.
3. Write a Dispatch client to interact with the service
4. Run the Dispatch client against the service implementation deployed in the Axis2 server
This address book sample is based on one of the jaxws-integration tests:
modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addressbook
Note that this is a very simple example, and does not persist any data. The intent is
to illustrate the use of JAXB objects with JAX-WS, not to actually implement and address book.
The following source is included with this example:
src\AddressBookEntry.xsd: Schema used to generate JAXB artifacts
src\org\apache\axis2\jaxws\addressbook\AddressBook.java: JAXWS Service Endpoint Interface (SEI)
Note that this SEI is NOT CURRENTLY USED in this example.
src\org\apache\axis2\jaxws\addressbook\AddressBookClient.java: JAXWS Dispatch Client
src\org\apache\axis2\jaxws\addressbook\AddressBookImpl.java: JAXWS service implementation
Step 0: How to build this sample
================================
To build this sample, execute the following maven command:
mvn clean install
This will do the following:
- Generate the JAXB artifacts (in target/schema)
- Compile the service implementation classes (in target/classes), including the JAXB artifacts,
and create a JAR containing those classes (target/jaxws-addressbook-SNAPSHOT.jar)
- Compile the Dispatch client classes (in target/classes) and create a JAR containing those classes
(target/jaxws-addressbook-SNAPSHOT-Client.jar).
Step 1: Generate JAXB artifacts from simple schema
==================================================
The file src/AddressBookEntry.xsd describes a simple AddressBookEntry object with the
following fields:
String firstName;
String lastName;
String phone;
String street;
String city;
String state;
The following JAXB artifacts are generated in the target/schema/src directory when the
sample is built
org\apache\axis2\jaxws\addressbook\AddressBookEntry.java
org\apache\axis2\jaxws\addressbook\ObjectFactory.java
org\apache\axis2\jaxws\addressbook\package-info.java
These files will be compiled into target/classes as part of the build.
Step 2: Write a JAX-WS service implementation using the JAXB artifacts
======================================================================
The simple service implementation will have two methods on it:
public String addEntry(String firstName, String lastName, String phone, String street, String city, String state)
public AddressBookEntry findByLastName(String lastName)
The service implementation does not explicitly specify a JAX-WS SEI. The public methods on the
implementation will be an implicit SEI. Simply by adding an @WebService annotation to the
implementation class it becomes a JAX-WS web service.
The implementation class is: src\org\apache\axis2\jaxws\addressbook\AddressBookImpl.java
This file will be compiled into target/classes as part of the build.
Step 3: Write a JAX-WS Dispatch client to interact with the service
===================================================================
The extremely simple Dispatch client will be a Payload mode String Dispatch client, meaning that
it will provide the exact SOAP body to send in the request (Payload mode) as a String, and expect
the response to be a SOAP body returned as a String. It will invoke both methods on the
service implenetation's implicit SEI.
The dispatch client class is: src\org\apache\axis2\jaxws\addressbook\AddressBookClient.java
This file will be compiled into target/classes as part of the build.
Step 4: Run the Dispatch client against the service implementation deployed in the Axis2 server
===============================================================================================
(a) Setup your environment to run the sample. You will need two windows, one for the server
and one for the client. Each needs the following environment variables set:
- Axis2 binary distribution. For example: AXIS2_HOME=C:\temp\Axis2\axis2-SNAPSHOT
- Java5 JDK. For example: JAVA_HOME=c:\java\java5
(b) Copy the service implementation JAR file from the sample target directory to the appropriate
Axis2 repository directory, %AXIS2_HOME%\repository\servicejars. Note that JAR files in this
directory will be deployed into the Axis2 simple server using only annotations on classes
within the JARs; no deployment descriptor is required.
If the repository directory does not exist, create it first, then copy the service
implementation JAR:
mkdir %AXIS2_HOME%\repository\servicejars
copy target\jaxws-addressbook-SNAPSHOT.jar %AXIS2_HOME%\repository\servicejars
(c) Start the axis2 server. This will deploy the JAX-WS service implementation.
cd %AXIS2_HOME%
bin\axis2server.bat
You should see a message such as:
[INFO] Deploying artifact : jaxws-addressbook-SNAPSHOT.jar
[INFO] Deploying JAXWS annotated class org.apache.axis2.jaxws.addressbook.AddressBookImpl as a service - AddressBookImplService.AddressBookImplPort
(d) From another window with the environment setup, in the jaxws-addressbook samples directory run
the Dispatch client:
java -Djava.ext.dirs=%AXIS2_HOME%\lib;%JAVA_HOME%\jre\lib\ext -cp target/classes org.apache.axis2.jaxws.addressbook.AddressBookClient.class
You should see something like the following in the client window:
>> Invoking sync Dispatch for AddEntry
Add Entry response: <dlwmin:addEntryResponse xmlns:dlwmin="http://addressbook.jaxws.axis2.apache.org/"><return xmlns:ns2
="http://addressbook.jaxws.axis2.apache.org">AddEntry Completed!</return></dlwmin:addEntryResponse>
>> Invoking Dispatch for findByLastName
Find response: <dlwmin:findByLastNameResponse xmlns:dlwmin="http://addressbook.jaxws.axis2.apache.org/"><return xmlns:ns
2="http://addressbook.jaxws.axis2.apache.org"><firstName>firstName</firstName><lastName>lastName</lastName><phone>phone<
/phone><street>street</street><city>city</city><state>state</state></return></dlwmin:findByLastNameResponse>
没有合适的资源?快使用搜索试试~ 我知道了~
WSDL2Java及axis2-1.5-bin.zip的包
共450个文件
java:146个
jar:63个
txt:63个
4星 · 超过85%的资源 需积分: 10 383 下载量 130 浏览量
2009-06-25
10:01:49
上传
评论 1
收藏 19.62MB ZIP 举报
温馨提示
使用axis2-1.5开发包 从最简单的开始 ,-uri 指定wsdl文件> WSDL2Java -uri currencyConvert.wsdl-d 使用不同的data binding方法> WSDL2Java -uri currencyConvert.wsdl -d xmlbeans-a 生成异步的方法> WSDL2Java -uri currencyConvert.wsdl -a-t 生成测试case> WSDL2Java -uri currencyConvert.wsdl -t ...稍微复杂一些的,-p可以指定生成的package,-o指定生成的路径,-ss生成服务端代码wsdl2java -uri ../wsdl/currencyConvert.wsdl -o ../gen_src -ss -sd -g -p foo.bat再复杂一些,-ns2p 将namespace进行替换,多个中间用逗号隔开wsdl2java -uri ../wsdl/currencyConvert.wsdl -o ../wsdl/gen_src -ss -sd -g -p com.foo.bar -ns2p "http://www.xxx.yyy.com/zzz/v1.0"=com.foo.bar," 命令参数说明: ? -d 生成客户端执行类的class文件的存放目录? ? -s 生成客户端执行类的源文件的存放目录? ? -p 定义生成类的包名?
资源推荐
资源详情
资源评论
收起资源包目录
WSDL2Java及axis2-1.5-bin.zip的包 (450个子文件)
version-1.5.aar 4KB
version.aar 2KB
version-1.5-sources.jar.asc 202B
version-1.5.pom.asc 202B
version-1.5.aar.asc 202B
axis2server.bat 3KB
java2wsdl.bat 3KB
wsdl2java.bat 3KB
axis2.bat 3KB
AdminAgent.class 18KB
AxisAdminServlet.class 2KB
Version.class 655B
Version.class 655B
axis-style.css 2KB
asf-logo.gif 6KB
axis.gif 2KB
servicelifecycleguide.html 8KB
FaultHandlingSampleGuide.html 6KB
release-notes.html 4KB
index.html 2KB
AuthError.html 1KB
GenError.html 1KB
footer.inc 1KB
header.inc 1KB
adminheader.inc 1KB
link-footer.inc 927B
adminfooter.inc 903B
jaxb-xjc-2.1.7.jar 2.98MB
xalan-2.7.0.jar 2.6MB
xmlbeans-2.3.0.jar 2.54MB
jalopy-1.5rc3.jar 1.27MB
xercesImpl-2.6.2.jar 987KB
axis2-kernel-1.5.jar 972KB
jaxb-impl-2.1.7.jar 835KB
axis2-adb-1.5.jar 759KB
axis2-jaxws-1.5.jar 629KB
wstx-asl-3.2.4.jar 508KB
bcel-5.1.jar 504KB
smackx-3.0.4.jar 464KB
jibx-bind-1.2.1.jar 399KB
axis2-metadata-1.5.jar 383KB
log4j-1.2.15.jar 383KB
mail-1.4.jar 380KB
commons-httpclient-3.1.jar 298KB
smack-3.0.4.jar 262KB
axiom-api-1.2.8.jar 240KB
commons-lang-2.3.jar 240KB
axis2-codegen-1.5.jar 238KB
jaxen-1.1.1.jar 222KB
woden-impl-dom-1.0M8.jar 220KB
xml-apis-1.3.02.jar 190KB
httpcore-4.0.jar 169KB
axis2-adb-codegen-1.5.jar 164KB
axiom-dom-1.2.8.jar 158KB
woden-api-1.0M8.jar 146KB
wsdl4j-1.6.2.jar 145KB
axis2-transport-http-1.5.jar 141KB
XmlSchema-1.4.3.jar 140KB
axis2-corba-1.5.jar 138KB
axiom-impl-1.2.8.jar 128KB
jibx-run-1.2.1.jar 126KB
commons-io-1.4.jar 106KB
axis2-clustering-1.5.jar 100KB
jaxb-api-2.1.jar 88KB
axis2-saaj-1.5.jar 87KB
xml-resolver-1.2.jar 82KB
axis2-fastinfoset-1.5.jar 70KB
activation-1.1.jar 62KB
commons-logging-1.1.1.jar 59KB
jettison-1.0-RC2.jar 53KB
commons-fileupload-1.2.jar 52KB
geronimo-jaxws_2.1_spec-1.0.jar 47KB
commons-codec-1.3.jar 46KB
axis2-jibx-1.5.jar 35KB
mex-1.5.jar 33KB
neethi-2.0.4.jar 32KB
soapmonitor-1.5.jar 31KB
geronimo-saaj_1.3_spec-1.0.1.jar 29KB
geronimo-stax-api_1.0_spec-1.0.1.jar 28KB
axis2-xmlbeans-1.5.jar 26KB
axis2-java2wsdl-1.5.jar 25KB
axis2-jaxbri-1.5.jar 25KB
axis2-json-1.5.jar 16KB
axis2-ant-plugin-1.5.jar 16KB
geronimo-ws-metadata_2.0_spec-1.1.2.jar 14KB
axis2-mtompolicy-1.5.jar 13KB
geronimo-annotation_1.0_spec-1.1.jar 12KB
axis2-spring-1.5.jar 11KB
axis2-transport-local-1.5.jar 11KB
version-1.5-sources.jar 2KB
SampleClient.java 23KB
ObjectFactory.java 22KB
SampleMTOMTests.java 16KB
InteropSampleService.java 13KB
ObjectFactory.java 12KB
IBaseDataTypesDocLitB.java 12KB
LibraryServiceClient.java 12KB
EchoPingSampleServlet.java 9KB
MTOMSampleServlet.java 9KB
LibraryLifeCycle.java 8KB
共 450 条
- 1
- 2
- 3
- 4
- 5
lhsxsh
- 粉丝: 75
- 资源: 84
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于ESP8266的WebDAV服务器与3D打印机管理系统.zip
- (源码)基于Nio实现的Mycat 2.0数据库代理系统.zip
- (源码)基于Java的高校学生就业管理系统.zip
- (源码)基于Spring Boot框架的博客系统.zip
- (源码)基于Spring Boot框架的博客管理系统.zip
- (源码)基于ESP8266和Blynk的IR设备控制系统.zip
- (源码)基于Java和JSP的校园论坛系统.zip
- (源码)基于ROS Kinetic框架的AGV激光雷达导航与SLAM系统.zip
- (源码)基于PythonDjango框架的资产管理系统.zip
- (源码)基于计算机系统原理与Arduino技术的学习平台.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页