6-10 Getting Started With JAX-RPC Web Services for Oracle WebLogic Server
The following list describes the changes you must make to the JWS file that implements the client Web service; see
Section 6.3.2, Sample JWS File That Invokes a Web Service
for the full JWS file example.
■
Import the files generated by the clientgen child element of the jwsc Ant task. These include the JAX-RPC stubs of the invoked Web service, as well as the
Java representation of any user-defined data types used as parameters or return values in the operations of the invoked Web service.
■
Update the method that contains the invoke of the Web service to either throw or catch both java.rmi.RemoteException and
javax.xml.rpc.ServiceException .
■
Get the Service and PortType JAX-RPC stubs implementation and invoke the operation on the port as usual; see
Section 6.2.3, Writing the Java Client Application Code to Invoke a Web Service
for details.
6.3.1 Sample build.xml File for a Web Service Client
The following sample build.xml file shows how to create a Web service that itself invokes another Web service; the relevant sections that differ from the build.xml for
building a simple Web service that does not invoke another Web service are shown in bold
. The build-service target in this case is very similar to a target that builds a simple
Web service; the only difference is that the jwsc Ant task that builds the invoking Web service also includes a clientgen child element of the jws element so that
jwsc also generates the required JAX-RPC client stubs.
project name=webservices-service_to_service default=all -- set global properties for this build --
property name=wls.username value=weblogic property name=wls.password value=weblogic
property name=wls.hostname value=localhost property name=wls.port value=7001
property name=wls.server.name value=myserver property name=ear.deployed.name value=ClientServiceEar
property name=example-output value=output property name=ear-dir value={example-output}ClientServiceEar
property name=clientclass-dir value={example-output}clientclasses path id=client.class.path
pathelement path={clientclass-dir} pathelement path={java.class.path}
path taskdef name=jwsc
classname=weblogic.wsee.tools.anttasks.JwscTask taskdef name=clientgen
classname=weblogic.wsee.tools.anttasks.ClientGenTask taskdef name=wldeploy
classname=weblogic.ant.taskdefs.management.WLDeploy target name=all depends=clean,build-service,deploy,client
target name=clean depends=undeploy
Note: The user-defined data types are generated into a package
based on the XML Schema of the data type in the WSDL, not in the package specified by clientgen. The JAX-RPC stubs, however, use
the package name specified by the packageName attribute of the clientgen
element.
Invoking Web Services 6-11
delete dir={example-output} target
target name=build-service jwsc
srcdir=src destdir={ear-dir}
jws file=exampleswebservicesservice_to_serviceClientServiceImpl.java
type=JAXRPC clientgen
wsdl=http:{wls.hostname}:{wls.port}complexComplexService?WSDL packageName=examples.webservices.complex
jws jwsc
target target name=deploy
wldeploy action=deploy name={ear.deployed.name} source={ear-dir} user={wls.username}
password={wls.password} verbose=true adminurl=t3:{wls.hostname}:{wls.port}
targets={wls.server.name} target
target name=undeploy wldeploy action=undeploy name={ear.deployed.name}
failonerror=false user={wls.username}
password={wls.password} verbose=true adminurl=t3:{wls.hostname}:{wls.port}
targets={wls.server.name} target
target name=client clientgen
wsdl=http:{wls.hostname}:{wls.port}ClientServiceClientService?WSDL destDir={clientclass-dir}
packageName=examples.webservices.service_to_service.client type=JAXRPC
javac srcdir={clientclass-dir} destdir={clientclass-dir}
includes=.java javac
srcdir=src destdir={clientclass-dir} includes=exampleswebservicesservice_to_serviceclient.java
target target name=run
java classname=examples.webservices.service_to_service.client.Main fork=true
failonerror=true classpath refid=client.class.path
arg line=http:{wls.hostname}:{wls.port}ClientServiceClientService
java target
project
6-12 Getting Started With JAX-RPC Web Services for Oracle WebLogic Server
6.3.2 Sample JWS File That Invokes a Web Service