Title: JBoss at Work Chapter 10 Web Services
1JBoss at WorkChapter 10Web Services
- COSC617, FALL 2006, Jeff Schmitt
Presenters Steven R. Bussow Givry Mbouna
2Web Services - useful to JAW Motors?
- Jaw Motors has J2EE-based web site
- Wish to partner with Virtual Big Auto Dealership,
(VBAD), so to benefit from VBADs high-traffic
web site which markets auto dealer inventories - One problem - VBAD doesnt use J2EE
3Web Services solution to cross-platform
- Deploy a portion of JAW Motors application,
(inventory), as a Web Service so it can work with
non-Java clients - Show EJB as a Web Service by using XDocklet and
Java Web Services Developer Pack (JWSDP) to
deploy it on JBoss - Bridge the gap by writing an Axis client to
use/consume our Web Service
4Web Services invocation
- VBADs web site acts as the external client,
invoking JAW Motors findAvailableCars() Web
Service to get inventory information - Client uses a Web Service proxy object to marshal
the method findAvailableCars() call as a Simple
Object Access Protocol (SOAP) Request and sends
it to the JBoss application server - The SOAP Servlet receives SOAP Request, looks up
findAvailableCars() service in Web Service
Definition Language (WSDL) file, and then invokes
findAvailableCars() method on behalf of the
client - findAvailableCars() method finds desired
inventory info and packages it into CarDTO
objects, then returns control to the SOAP Servlet - SOAP Servlet marshals the CarDTO objects into
SOAP Response, returns response to caller /
client - Web Service proxy object (back on client)
unmarshals the SOAP Response into CarDTO objects
to display on the VBAD web site
5Web Services invocation
JBOSS
SOAP request / response
Web service client
SOAP Servlet
findAvailableCars() (inventory EJB)
WSDL
6Web Services terminology
- SOAP an XML-based, platform neutral, wire
protocal that enables remote communication.
Client and server communicate using SOAP Messages
that contain a Header and a Body. Header holds
routing information, Body holds request /
response data. - WSDL XML-based interface descriptor that
describes a web service interface along with its
parameters. WSDL registers your Web Service with
your server in the same way web.xml registers
Servlets and ejb-jar.xml registers EJBs. - Web Service Proxy set of objects that work
together to encapsulate low-level SOAP
communication details and invoke a Web Service on
behalf of a client. SOAP toolkits are available
for most programming languages that user the WSDL
to generate Web Serviced proxy code for the
language of the intended client - SOAP Servlet as of J2EE 1.4, most application
servers use a Servlet to listen for SOAP
Requests, rout them to a Web Service, and return
the result(s) as a SOAP Response
7Web Services JBoss background
- JBoss.NET was used to deploy Web Services, but
too proprietary - JBossWS is JBosss new J2EE 1.4-complient Web
Service implementation, based on Apache Axis and
uses J2EE standard deployment descriptors and
technology, most bugs were removed in JBoss
4.01sp1 - Server requires us to create a Service Endpoint
Interface and register it with the deployment
descriptors. - We can implement a Service Endpoint as a Servlet
or POJO deployed in a WAR file, or as a Stateless
Session Bean, but, we observe the EJB Service
Endpoints in our example
8Implementing J2EE 1.4 Web Services
- To expose InventoryFacadeBeans
findAvailableCars() method as a J2EE 1.4
compliant Web Service, we must do the following
(mostly now automated with Ant, XDoclet, and
JWSDP) - Create a Service Endpoint Interface (SEI) to
expose EJB methods as Web Service operations - Add a ltservice-endpointgt element to ejb-jar.xml
to tell JBoss that the InventoryFacadeBean EJB
implements the InventoryEndpoint Service Endpoint
Interface - Generate the webservices.xml to register the Web
Service and tie the InventoryEndpoint Service
Endpoint Interface to an implementation the
InventoryFacadeBean - Create a JAX-RPC Mapping File to define JAX-RPC
type mappings for the parameters and return
values for the InventoryEndpoints methods - Generate a WSDL to define the Web Service and tie
it to XML Schema data types - Set the Web Service URL by modifying jboss.xml
with the Inventory Web Service URL - Modify our EJB, the Inventory FacadeBean
- Add Web Services-related XDoclet tags
- Add the findAvailableCars() method and use an XML
Schema-compatible data type - Upgrade the Deployment by modifying the Ant build
script
9Service EndPoint Interface (SEI)
- SEI exposes business methods as Web Services that
can be accessed by external clients - SEI acts as a server-side stub that shows your
business methods to clients and serves the same
purpose for a Web Service that an EJB Remote
Interface does for an EJB - The InventoryEndpoint interface is a Remote
interfcae, and the findAvailable Cars() method
throws a Remote Exception - The CarDTOArray (that holds an array of CarDTO
objects) is returned by the findAvailable Cars()
method - /InventoryEndpoint.java example/
- package com.jbossatwork.ws
- /
- Service endpoint interface for
InventoryFacade. - /
- public interface InventoryEndpoint
- extends java.rmi.Remote
-
10Modifying ejb-jar.xml
- We already generated the ejb-jar.xml descriptor
to deploy EJBs - Now we have to add a ltservice-endpointgt element
to that ejb-jar.xml - The ltservice-endpointgt will tell JBoss that the
InventoryFacadeBean EJB implements the
InventoryEndpoint interface
/ ejb-jar.xml example / ltenterprise-bea
nsgt ltsessiongt
ltdisplay-namegtInventoryFacadeSBlt/display-namegt
ltejb-namegtInventoryFacadelt/ejb-namegt
ltservice-endpointgtcom.jbossatwork.ws.InventoryEnd
pointlt/service-endpointgt lt/sessiongt
lt/enterprise-beansgt
11webservices.xml
- The webservices.xml file defines and registers
the InventoryService Web Service Endpoint, and
ties the Service Endpoint Interface class
(com.jbossatwork.ws.InventoryEndpoint) to the
InventoryFacadeBean EJB - Our webservices.xml file example also tells JBoss
where to find the WSDL and JAX-RPC Mapping files
in the EJB JAR file
12webservices.xml example
- lt?xml version"1.0" encoding"UTF-8"?gt
- ltwebservices
- xmlns"http//java.sun.com/xml/ns/j2ee"
- xmlnsxsi"http//www.w3.org/2001/XMLSchema-insta
nce" - xsischemaLocation"http//java.sun.com/xml/ns/j2
ee - http//www.ibm.com/webservices/xsd/j2ee_web_servic
es_1_1.xsd" - version"1.1"gt
- ltwebservice-descriptiongt
- ltwebservice-description-namegtInventoryServ
icelt/webservice-description-namegt - ltwsdl-filegtMETA-INF/wsdl/InventoryService.
wsdllt/wsdl-filegt - ltjaxrpc-mapping-filegtMETA-INF/inventory-ma
pping.xmllt/jaxrpc-mapping-filegt - ltport-componentgt
- ltport-component-namegtInventorylt/port-c
omponent-namegt - ltwsdl-portgtInventoryEndpointPortlt/wsdl
-portgt - ltservice-endpoint-interfacegt
- com.jbossatwork.ws.InventoryEndpoi
nt - lt/service-endpoint-interfacegt
- ltservice-impl-beangt
- ltejb-linkgtInventoryFacadelt/ejb-
linkgt
13JAX-RPC Mapping file
- The JAX-RPC mapping file helps the compiler map
Java objects to WSDL objects - Our JAX-RPC mapping file tells JBoss that the
InventoryEndpoint Service Endpoint Interface has
a findAvailableCars() method that takes no
parameters and returns a CarDTOArray - Each ltjava-xml-type-mappinggt element in the
JAX-RPC mapping file lists each of the Java
objects data members with a ltvariable-mappinggt
sub-element (it gets fairly tedious) - Notice how our example return type, CarDTOArray,
expands into two ltjava-xml-type-mappinggt elements - One for the CarDTOArray itself
- One for the CarDTO
14JAX-RPC Mapping file example
- lt?xml version"1.0" encoding"UTF-8"?gt
- ltjava-wsdl-mapping xmlns"http//java.sun.com/xml/
ns/j2ee" - xmlnsxsi"http//www.w3.org/2001/XMLSchema-instan
ce" - xsischemaLocation"http//java.sun.com/xml/ns/j2e
e - http//www.ibm.com/webservices/xsd/j2ee_jaxrpc_ma
pping_1_1.xsd" version"1.1"gt - ltpackage-mappinggt
- ltpackage-typegtcom.jbossatwork.wslt/package-type
gt - ltnamespaceURIgthttp//localhost8080/jbossatwor
k-ws/typeslt/namespaceURIgt - lt/package-mappinggt
- ltpackage-mappinggt
- ltpackage-typegtcom.jbossatwork.wslt/package-type
gt - ltnamespaceURIgthttp//localhost8080/jbossatwor
k-wslt/namespaceURIgt - lt/package-mappinggt
- ltjava-xml-type-mappinggt
- ltjava-typegtcom.jbossatwork.dto.CarDTOArraylt/ja
va-typegt - ltroot-type-qname xmlnstypeNS"http//localhos
t8080/jbossatwork-ws/types"gt - typeNSCarDTOArray
- lt/root-type-qnamegt
- ltqname-scopegtcomplexTypelt/qname-scopegt
15JAX-RPC Mapping file example continued
- ltjava-xml-type-mappinggt
- ltjava-typegtcom.jbossatwork.dto.CarDTOlt/java-ty
pegt - ltroot-type-qname xmlnstypeNS"http//localhos
t8080/jbossatwork-ws/types"gt - typeNSCarDTO
- lt/root-type-qnamegt
- ltqname-scopegtcomplexTypelt/qname-scopegt
- ltvariable-mappinggt
- ltjava-variable-namegtidlt/java-variable-namegt
- ltxml-element-namegtidlt/xml-element-namegt
- lt/variable-mappinggt
- ltvariable-mappinggt
- ltjava-variable-namegtmakelt/java-variable-name
gt - ltxml-element-namegtmakelt/xml-element-namegt
- lt/variable-mappinggt
- ltvariable-mappinggt
- ltjava-variable-namegtmodellt/java-variable-nam
egt - ltxml-element-namegtmodellt/xml-element-namegt
- lt/variable-mappinggt
- ltvariable-mappinggt
16JAX-RPC Mapping file example concluded
- variable-mappinggt
- ltjava-variable-namegtstatuslt/java-variable-na
megt - ltxml-element-namegtstatuslt/xml-element-namegt
- lt/variable-mappinggt
- lt/java-xml-type-mappinggt
- ltservice-interface-mappinggt
- ltservice-interfacegtcom.jbossatwork.ws.Inventor
yServicelt/service-interfacegt - ltwsdl-service-name xmlnsserviceNS"http//loc
alhost8080/jbossatwork-ws"gt - serviceNSInventoryService
- lt/wsdl-service-namegt
- ltport-mappinggt
- ltport-namegtInventoryEndpointPortlt/port-namegt
- ltjava-port-namegtInventoryEndpointPortlt/java-
port-namegt - lt/port-mappinggt
- lt/service-interface-mappinggt
- ltservice-endpoint-interface-mappinggt
- ltservice-endpoint-interfacegt
- com.jbossatwork.ws.InventoryEndpoint
- lt/service-endpoint-interfacegt
17WSDL File
- WSDL file describes a Web Service interface along
with its parameters and registers the web service
with JBoss. - Our WSDL file ties the InventoryService web
service to the InventoryEndpoint interface and
maps the CarDTO and CarDTOArray WSDL types to XSD
data types - This line in the WSDL file tells JBoss that it
can choose its own URL for the web service - ltsoapaddress locationPUT_YOUR_OWN_URL_HERE/gt
- Without the above line, JBoss deploys our WSDL to
the following default URL - http//localHost8080/jaw/ejb/Inventory?wsdl
18WSDL File example
- lt?xml version"1.0" encoding"UTF-8"?gt
- ltdefinitions name"InventoryService"
- targetNamespace"http//localhost8080/jbossatwork
-ws" - xmlnstns"http//localhost8080/jbossatwork-ws"
- xmlns"http//schemas.xmlsoap.org/wsdl/"
- xmlnsxsd"http//www.w3.org/2001/XMLSchema"
- xmlnsns2"http//localhost8080/jbossatwork-ws/ty
pes" - xmlnssoap"http//schemas.xmlsoap.org/wsdl/soap/"
gt - lttypesgt
- ltschema targetNamespace"http//localhost8080
/jbossatwork-ws/types" - xmlnstnshttp//localhost8080/jbossa
twork-ws/types - xmlnssoap11-enc"http//schemas.xmlso
ap.org/soap/encoding/" - xmlnsxsi"http//www.w3.org/2001/XMLS
chema-instance" - xmlnswsdl"http//schemas.xmlsoap.org
/wsdl/" - xmlns"http//www.w3.org/2001/XMLSchem
a"gt - ltcomplexType name"CarDTOArray"gt
- ltsequencegt
- ltelement name"cars" type"tnsCarDTO"
nillable"true" minOccurs"0" - maxOccurs"unbounded"/gtlt/sequen
cegt
19WSDL File example concluded
- ltmessage name"InventoryEndpoint_findAvailableCars
"/gt - ltmessage name"InventoryEndpoint_findAvailableCa
rsResponse"gt - ltpart name"result" type"ns2CarDTOArray"/gtlt/
messagegt - ltportType name"InventoryEndpoint"gt
- ltoperation name"findAvailableCars"gt
- ltinput message"tnsInventoryEndpoint_findAv
ailableCars"/gt - ltoutput message"tnsInventoryEndpoint_findA
vailableCarsResponse"/gt - lt/operationgt
- lt/portTypegt
- ltbinding name"InventoryEndpointBinding"
type"tnsInventoryEndpoint"gt - ltsoapbinding transport"http//schemas.xmlsoa
p.org/soap/http" style"rpc"/gt - ltoperation name"findAvailableCars"gt
- ltsoapoperation soapAction""/gt
- ltinputgt
- ltsoapbody use"literal"
namespace"http//localhost8080/jbossatwork-ws"/gt
- lt/inputgt
- ltoutputgt
- ltsoapbody use"literal"
namespace"http//localhost8080/jbossatwork-ws"/gt
- lt/outputgt
20Set the Web Service URL
- If we want to use a meaningful URL to match our
Web Service namespace, jbossatwork-ws, we modify
the jboss.xml (the JBoss EJB deployment
descriptor) - The ltport-componentgt element and its sub-elements
tell JBoss to deploy our WSDL to the
jbossatwork-ws namespace at the following URL - http//localhost8080/jbossatwork-ws/InventoryServ
ice?wsdl - Remember, modifying the jboss.xml file to set our
URL is purely optional
21Set the Web Service URL jboss.xml example
- lt?xml version"1.0" encoding"UTF-8"?gt
- lt!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS
4.0//EN" - "http//www.jboss.org/j2ee/
dtd/jboss_4_0.dtd"gt - ltjbossgt
- ltenterprise-beansgt
-
- ltsessiongt
- ltejb-namegtInventoryFacadelt/ejb-namegt
- ltport-componentgt
- ltport-component-namegtInventorylt/port-compo
nent-namegt - ltport-component-urigtjbossatwork-ws/Invento
ryService - lt/port-component-urigt
- lt/port-componentgt
-
- lt/sessiongt
-
- lt/enterprise-beansgt
-
- lt/jbossgt
22Modify the InventoryFacadeBean EJB
- We add a new method called findAvailableCars()
which we are exposing as a Web Service - findAvailableCars() wraps the listAvailableCars()
method and converts its return value,
java.util.List, to a CarDTOArray - Setting the view-type to all in the class-level
_at_ejb.bean tag tells XDoclet to generated the
Service Endpoint Interface along with the EJB
Remote and Local Component interfaces - Setting the veiw-type to both in the class-level
_at_ejb.interface-method tells XDoclet to exclude
all other business methods from the Service
Endpoint Interface
23Modify the InventoryFacadeBean EJB example
- /
- _at_ejb.bean
- name"InventoryFacade"
-
- view-type"all"
-
-
- _at_wsee.port-component
- name"Inventory"
- wsdl-port"InventoryEndpointPort"
- service-endpoint-interface"com.jbossatwork.ws
.InventoryEndpoint" - service-endpoint-bean"com.jbossatwork.ejb.Inv
entoryFacadeBean" -
- _at_ejb.interface
- service-endpoint-class"com.jbossatwork.ws.Inv
entoryEndpoint" -
- /
- public class InventoryFacadeBean implements
SessionBean -
24Web Services Data Types
- Real world data types get complex
- Our InventoryEndpoint.java, for example
-
- public com.jbossatwork.dto.CarDTOArray
findAvailableCars() throws java.rmi.RemoteExceptio
n - ...
- findAvailableCars() returns a CarDTOArray object
that encapsulates an array of CarDTO objects - Each application-specific class must follow the
JavaBeans conventions - It must have a default constructor
- Each private or protected data member must have a
corresponding public getter and setter
25Web Services Data Types continued
- Our CarDTO make data member is a String, so the
getter and setter must look as follows - private String make
-
- public String getMake()
- return make
-
- public void setMake(String make)
- this.make make
26Web Services and Collections
- J2EE Web Services cannot exchange Collections or
arrays of custom data types - Solution wrap your array in a JavaBean
- We must wrap an array of CarDTOs in a CarDTOArray
object - Though a somewhat complex solution, we reach the
Web Service goal of interoperability
package com.jbossatwork.dto import
java.io.Serializable import com.jbossatwork.dto.C
arDTO public class CarDTOArray implements
Serializable private CarDTO cars
public CarDTOArray() public CarDTO
getCars() return cars
public void setCars(CarDTO cars)
this.cars cars
27Web Services Deployment
- EJB JAR file structure
- Automating web services deployment
- Tools
- Ant Script
28EJB JAR file structure
- The new files go into the EJB JAR file as
follows - META-INF/
- ejb-jar.xml
- jboss.xml
- webservices.xml
- Inventory-mapping.xml( the JAX-RPC mapping file)
- wsdl/
- InventoryService.wsdl
- com/jbossatwork/ws/
- InventoryEndpoint.class
- Everything else remains unchanged
29Automating Web Services DeploymentWhat are we
automating?
- Create three new descriptors
- webservices.xml
- JAX-RPC Mapping file
- WSDL
- Generate Service Endpoint Interface
- Modify both EJB deployment descriptors
- ejb-jar.xml
- jboss.xml
-
30What About the Tools?
- XDoclet has limited support for Web Services
- Can generate (with minor mistakes)
- Service Endpoint Interface
- webservice.xml
- Modify ejb-jar.xml
- Ant fixes XDoclets mistakes
- JWSDP (Java Web Services Developers Pack)
- Generate WSDL and JAX-RPC Mapping Files
31Web Services Ant Script
- Generate Service Endpoint Interface
- Fix the URL
- Generate webservices.xml
- Fix webservices.xml
- Generate JAX-RPC Mapping and WSDL files
32Ant Script Generate Service Endpoint Interface
- ltproperty name"jwsdp.lib.dir" value"/Library/jws
dp-1.5"/gt -
- lttarget name"run-ejbdoclet" gt
- ltejbdoclet gt
-
-
- ltservice-endpoint/gt
-
-
- lt/ejbdocletgt
- lt!-- Fix problems with XDoclet-generated
Service Endpoint Interface --gt -
- ltreplace file"gen.source.dir/c
om/jbossatwork/ws/InventoryEndpoint.java"gt - ltreplacetokengtlt!CDATAthrows
javax.ejb.EJBException, - java.rmi.RemoteExceptiongtlt/replacetokengt
- ltreplacevaluegtlt!CDATAthrows
java.rmi.RemoteExceptiongtlt/replacevaluegt - lt/replacegt
33Ant Script Fix the URL
- lt!-- Fix WS URL in jboss.xml --gt
-
- ltreplace file"gen.source.dir/jboss.xml
"gt - ltreplacetokengtlt!CDATAltejb-namegtInvento
ryFacadelt/ejb-namegtgt - lt/replacetokengt
- ltreplacevaluegtlt!CDATA
- ltejb-namegtInventoryFacadelt
/ejb-namegt - ltport-componentgt
- ltport-component-namegtInv
entorylt/port-component-namegt - ltport-component-urigtjbos
satwork-ws/InventoryService - lt/port-component-urigt
- lt/port-componentgt
- gtlt/replacevaluegt
- lt/replacegt
- lt/targetgt
34Ant Script Generate webservices.xml
-
- lttarget name"run-wseedoclet" depends"run-ejbdocl
et"gt - lttaskdef name"wseedoclet"
- classname"xdoclet.modules.wsee.W
seeDocletTask" - classpathref"xdoclet.lib.path"/gt
- ltwseedoclet wsdlFile"META-INF/wsdl/Invent
oryService.wsdl" - jaxrpcMappingFile"META-INF/in
ventory-mapping.xml" - wseeSpec"1.1"
- destdir"gen.source.dir"
- excludedtags"_at_version,_at_author
" - addedtags"_at_xdoclet-generated
at TODAY" - verbose"true"gt
-
- ltfileset dir"source.dir"gt
- ltinclude name"/Bean.java"/gt
- lt/filesetgt
-
- ltdeploymentdescriptor
name"InventoryService"/gt - lt/wseedocletgt
35Ant Script Fix webservices.xml
- lt!-- Fix problems with XDoclet-generated
webservices.xml --gt -
- ltreplace file"gen.source.dir/webservic
es.xml"gt - ltreplacetokengtlt!CDATAltwsdl-filegtWEB-
INF/gtlt/replacetokengt - ltreplacevaluegtlt!CDATAltwsdl-filegtgtlt
/replacevaluegt - lt/replacegt
- ltreplace file"gen.source.dir/webservic
es.xml"gt - ltreplacetokengtlt!CDATAltjaxrpc-mapping
-filegtWEB-INF/gtlt/replacetokengt - ltreplacevaluegtlt!CDATAltjaxrpc-mapping
-filegtgtlt/replacevaluegt - lt/replacegt
-
- ltreplace file"gen.source.dir/webservic
es.xml"gt - ltreplacetokengtlt!CDATAlticongtgtlt/repl
acetokengt - ltreplacevaluegtlt!CDATAgtlt/replaceval
uegt - lt/replacegt
-
- ltreplace file"gen.source.dir/webservic
es.xml"gt - ltreplacetokengtlt!CDATAlt/icongtgtlt/rep
lacetokengt - ltreplacevaluegtlt!CDATAgtlt/replaceval
uegt
36Ant Script Generate JAX-RPC Mapping and WSDL
files
-
- lttarget name"run-wscompile" depends"compile"gt
- ltecho message"Generating JAX-RPC Mapping
and WSDL files."/gt -
- ltpath id"wscompile.task.classpath"gt
- ltfileset dir"jwsdp.lib.dir"gt
- ltinclude name"/.jar"/gt
- lt/filesetgt
- ltfileset dir"java.home/../lib"
includes"tools.jar"/gt - lt/pathgt
-
-
- ltwscompile base"build.dir"
- fork"true"
- server"true"
- features"rpcliteral"
- mapping"gen.source.dir/inve
ntory-mapping.xml" - config"wscompile-config.xml"
- nonClassDir"gen.source.dir"
gt
37J2EE Web Services Checklist
- Created the InventoryEndpoint Service Interface
(SEI) to expose EJB methods as Web service
operations - Added a ltservice-endpointgt element to ejb-jar.xml
to tell JBoss that the InventoryFacadeBean EJB
implements the InventoryEndpoint Service Endpoint
Interface - Generated the webservices.xml to register the Web
Service and tie the InventoryEndpoint Service
Endpoint Interface to an implementation- the
InventoryFacadeBean - Created the JAX-RPC Mapping File to define
JAX-RPC type mappings for the parameters and
return values for the InventoryEndpoints method
38J2EE Web Services Checklist...continued
- Generated the inventory-mapping.xml WSDL file to
define the Web Service and tie it to XML Schema
data types - Set the Web Service URL by modifying jboss.xml
with the Inventory Web Service URL - Modified the InventoryFacadeBean
- Upgraded deployment by modifying the Ant script
39Testing Web Services Deployment
- Here are the steps to build and deploy the
application - Type ant in the root directory of ch10 to build
the project - Shut down JBoss so the Ant script can clean up
the JBoss deployment area - Type ant colddeploy to deploy the EAR file
(jaw.ear) to the JBOSS_HOME/server/default/deploy
directory - Start JBoss back up
40Web Services Client
- In order to test the web service, we need to add
an external client application. So we would use a
well-known API for invoking the Inventory Web
Service methods. - JNDI
- JAX-RPC
- Apache Axis
- Perl, Python, C
41Implementing a Web Service Client
- Download the WSDL from http//localhost8080/jboss
atwork-ws/InventoryService?wsdl - Generate Web Service proxy and custom data type
objects by using the Axis WSDL2Java Ant task - Write a Web Service client that uses the
Axis-generated proxy and custom data type objects
to call the Web Service
42Generate Web Service Proxy Code
- ltpath id"axis.classpath"gt
- ltfileset dir"axis.lib.dir"gt
- ltinclude name"/.jar"/gt
- lt/filesetgt
- lt/pathgt
-
- lttarget name"run-wsdl2java"
description"Generates WS proxy code from WSDL"gt - ltpath id"wsdl2java.task.classpath"gt
- ltpath refid"axis.classpath"/gt
- lt/pathgt
-
- ltwsdl2java output"gen.source.dir"
- url"InventoryService.wsdl"
- verbose"true"gt
-
- ltmapping namespace"http//localhost8
080/jbossatwork-ws" - package"com.jbossatwork.clie
nt"/gt -
- ltmapping namespace"http//localhost8
080/jbossatwork-ws/types"
43Client Code
- package com.jbossatwork.client
- public class MyAxisClient
- public static void main(String args)
- try
- System.out.println("Finding
InventoryService ...\n") - InventoryService service new
InventoryServiceLocator() - System.out.println("Getting InventoryEndpoint
...\n") - InventoryEndpoint endpoint
service.getInventoryEndpointPort() - System.out.println("Getting Cars ...")
44Testing the Web Service Client
- After generating Web Service proxy code and
writing a client to call the findAvailableCars
Web Service, we would go to the ch10/client
sub-directory, and compile and run the client by
typing ant run-client
45Questions?