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.7.7-bin.zip下载 (511个子文件)
version-1.7.7.aar 9KB
axis2server.bat 4KB
java2wsdl.bat 3KB
wsdl2java.bat 3KB
axis2.bat 3KB
AdminActions.class 20KB
SOAPMonitorApplet$SOAPMonitorPage.class 13KB
AxisAdminServlet.class 6KB
SOAPMonitorApplet$SOAPMonitorTableModel.class 6KB
SOAPMonitorApplet$SOAPMonitorFilter.class 5KB
SOAPMonitorApplet$ServiceFilterPanel.class 5KB
CSRFPreventionResponseWrapper.class 4KB
SOAPMonitorApplet.class 4KB
Redirect.class 3KB
SOAPMonitorApplet$SOAPMonitorTextArea.class 3KB
ActionHandler.class 3KB
SOAPMonitorApplet$SOAPMonitorData.class 2KB
StatusCache.class 1KB
View.class 1KB
CSRFTokenCache.class 1KB
AxisAdminServlet.class 1KB
StatusCache$1.class 1KB
Status.class 707B
Action.class 570B
ActionResult.class 498B
axis-style.css 2KB
DEPENDENCIES 18KB
asf-logo.gif 6KB
axis.gif 2KB
servicelifecycleguide.html 8KB
FaultHandlingSampleGuide.html 6KB
index.html 2KB
AuthError.html 2KB
GenError.html 2KB
footer.inc 1KB
header.inc 1KB
adminfooter.inc 1KB
link-footer.inc 953B
xalan-2.7.0.jar 2.6MB
xmlbeans-2.5.0.jar 2.6MB
jaxb-xjc-2.2.6.jar 1.98MB
jalopy-1.5rc3.jar 1.27MB
jaxb-impl-2.2.6.jar 1.06MB
axis2-kernel-1.7.7.jar 1001KB
jaxws-tools-2.2.6.jar 819KB
axis2-jaxws-1.7.7.jar 733KB
httpclient-4.5.2.jar 719KB
axiom-dom-1.2.20.jar 699KB
axis2-adb-1.7.7.jar 639KB
bcel-findbugs-6.0.jar 598KB
axiom-impl-1.2.20.jar 559KB
woodstox-core-asl-4.2.0.jar 471KB
antlr-2.7.7.jar 435KB
axis2-metadata-1.7.7.jar 425KB
axiom-api-1.2.20.jar 414KB
jibx-bind-1.2.jar 398KB
log4j-1.2.15.jar 383KB
mail-1.4.jar 380KB
woden-core-1.0M10.jar 365KB
httpcore-4.4.4.jar 319KB
commons-httpclient-3.1.jar 298KB
axis2-codegen-1.7.7.jar 254KB
jaxen-1.1.6.jar 226KB
tribes-6.0.16.jar 223KB
taglibs-standard-impl-1.2.5.jar 202KB
axis2-adb-codegen-1.7.7.jar 179KB
stax2-api-3.1.1.jar 178KB
gson-2.1.jar 176KB
axis2-transport-http-1.7.7.jar 172KB
xmlschema-core-2.2.1.jar 168KB
commons-io-2.1.jar 159KB
axis2-corba-1.7.7.jar 151KB
wsdl4j-1.6.2.jar 145KB
jibx-run-1.2.jar 126KB
axis2-clustering-1.7.7.jar 106KB
axis2-transport-base-1.7.7.jar 103KB
jaxb-api-2.2.6.jar 97KB
jaxb-api-2.2.6.jar 97KB
apache-mime4j-core-0.7.2.jar 93KB
axis2-saaj-1.7.7.jar 92KB
jettison-1.3.8.jar 86KB
xml-resolver-1.2.jar 82KB
axis2-transport-jms-1.7.7.jar 78KB
neethi-3.0.3.jar 70KB
commons-fileupload-1.3.3.jar 69KB
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
axis2-json-1.7.7.jar 52KB
axis2-transport-xmpp-1.7.7.jar 51KB
jsr311-api-1.1.1.jar 45KB
axis2-transport-mail-1.7.7.jar 41KB
commons-cli-1.2.jar 40KB
taglibs-standard-spec-1.2.5.jar 39KB
axis2-jibx-1.7.7.jar 37KB
mex-1.7.7-impl.jar 34KB
axis2-soapmonitor-servlet-1.7.7.jar 33KB
axis2-soapmonitor-servlet-1.7.7.jar 33KB
axis2-java2wsdl-1.7.7.jar 31KB
共 511 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
- nyjmail2018-05-16不知道好不好用,下载下来看看
yuli_67
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功