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>
没有合适的资源?快使用搜索试试~ 我知道了~
axis2-1.6.3
共515个文件
java:147个
jar:80个
txt:73个
需积分: 0 1 下载量 38 浏览量
2022-02-21
10:37:27
上传
评论
收藏 19.85MB RAR 举报
温馨提示
1、用于生成WEBservice接口的java文件 2、配置环境变量 3、生成命令:wsdl2java -uri http://localhost:6380/LesDataSynService.asmx?wsdl -p org.tempuri -s -a -o D:\
资源详情
资源评论
资源推荐
收起资源包目录
axis2-1.6.3 (515个子文件)
version.aar 8KB
version-1.6.3.aar 8KB
version-1.6.3-javadoc.jar.asc 841B
version-1.6.3.pom.asc 841B
version-1.6.3-sources.jar.asc 841B
version-1.6.3.aar.asc 841B
axis2server.bat 4KB
java2wsdl.bat 3KB
wsdl2java.bat 3KB
axis2.bat 3KB
AdminAgent.class 18KB
AxisAdminServlet.class 2KB
AxisAdminServlet.class 1KB
Version.class 655B
Version.class 655B
stylesheet.css 2KB
axis-style.css 2KB
titlebar.gif 10KB
asf-logo.gif 6KB
axis.gif 2KB
background.gif 2KB
titlebar_end.gif 849B
tab.gif 291B
help-doc.html 8KB
Version.html 8KB
servicelifecycleguide.html 8KB
FaultHandlingSampleGuide.html 6KB
index-all.html 5KB
package-summary.html 4KB
release-notes.html 4KB
Version.html 4KB
package-tree.html 4KB
overview-tree.html 4KB
package-use.html 4KB
constant-values.html 4KB
deprecated-list.html 4KB
index.html 3KB
index.html 2KB
AuthError.html 1KB
GenError.html 1KB
package-frame.html 840B
allclasses-frame.html 710B
allclasses-noframe.html 690B
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
axis2-kernel-1.6.3.jar 1022KB
jaxb-impl-2.1.7.jar 835KB
axis2-jaxws-1.6.3.jar 727KB
axis2-adb-1.6.3.jar 673KB
bcel-5.1.jar 504KB
jaxws-tools-2.1.3.jar 497KB
woodstox-core-asl-4.1.4.jar 468KB
antlr-2.7.7.jar 435KB
axis2-metadata-1.6.3.jar 423KB
axiom-api-1.2.14.jar 412KB
jibx-bind-1.2.jar 398KB
log4j-1.2.15.jar 383KB
mail-1.4.jar 380KB
commons-httpclient-3.1.jar 298KB
axis2-codegen-1.6.3.jar 249KB
tribes-6.0.16.jar 223KB
jaxen-1.1.4.jar 221KB
axiom-dom-1.2.14.jar 207KB
woden-impl-commons-1.0M9.jar 182KB
axis2-adb-codegen-1.6.3.jar 178KB
stax2-api-3.1.1.jar 178KB
httpcore-4.0.jar 169KB
axiom-impl-1.2.14.jar 167KB
commons-io-2.1.jar 159KB
axis2-transport-http-1.6.3.jar 150KB
woden-api-1.0M9.jar 147KB
XmlSchema-1.4.7.jar 145KB
wsdl4j-1.6.2.jar 145KB
axis2-corba-1.6.3.jar 144KB
jibx-run-1.2.jar 126KB
axis2-clustering-1.6.3.jar 105KB
axis2-transport-base-1.6.3.jar 103KB
apache-mime4j-core-0.7.2.jar 93KB
axis2-saaj-1.6.3.jar 89KB
jaxb-api-2.1.jar 88KB
jaxb-api-2.1.jar 88KB
xml-resolver-1.2.jar 82KB
axis2-transport-jms-1.6.3.jar 78KB
jettison-1.3.jar 71KB
neethi-3.0.2.jar 70KB
activation-1.1.jar 62KB
commons-logging-1.1.1.jar 59KB
geronimo-jaxws_2.2_spec-1.0.jar 59KB
geronimo-jaxws_2.2_spec-1.0.jar 59KB
commons-fileupload-1.2.jar 52KB
axis2-transport-xmpp-1.6.3.jar 51KB
woden-impl-dom-1.0M9.jar 48KB
commons-codec-1.3.jar 46KB
共 515 条
- 1
- 2
- 3
- 4
- 5
- 6
Stdio_QU
- 粉丝: 175
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0