2-24 Getting Started With JAX-RPC Web Services for Oracle WebLogic Server
target name=deploy wldeploy action=deploy name=ClientServiceEar
source=ClientServiceEar user={wls.username} password={wls.password} verbose=true
adminurl=t3:{wls.hostname}:{wls.port} targets={wls.server.name}
target
Substitute the values for wls.username, wls.password, wls.hostname, wls.port
, and wls.server.name that correspond to your WebLogic Server instance.
Deploy the WAR file by executing the deploy target: prompt ant deploy
11.
Test that the Web service is deployed correctly by invoking its WSDL in your browser:
http:host:portClientServiceClientService?WSDL See
Section 2.4, Invoking a Web Service from a Java SE Client for an example of
creating a Java client application that invokes a Web service.
2.5.1 Sample ClientServiceImpl.java JWS File
The following provides a simple Web service client application that invokes the echoComplexType
operation. package examples.webservices.service_to_service;
import java.rmi.RemoteException; import javax.xml.rpc.ServiceException;
import javax.jws.WebService; import javax.jws.WebMethod;
import weblogic.jws.WLHttpTransport; Import the BasicStruct data type, generated by clientgen and used
by the ComplexService Web Service import examples.webservices.complex.BasicStruct;
Import the JAX-RPC Stubs for invoking the ComplexService Web Service. Stubs generated by clientgen
import examples.webservices.service_to_service.ComplexPortType; import examples.webservices.service_to_service.ComplexService_Impl;
import examples.webservices.service_to_service.ComplexService; WebServicename=ClientPortType, serviceName=ClientService,
targetNamespace=http:examples.org WLHttpTransportcontextPath=ClientService, serviceUri=ClientService,
portName=ClientServicePort public class ClientServiceImpl {
WebMethod public String callComplexServiceBasicStruct input, String serviceUrl
throws ServiceException, RemoteException {
Create service and port stubs to invoke ComplexService ComplexService service = new ComplexService_ImplserviceUrl + ?WSDL;
ComplexPortType port = service.getComplexServicePort; Invoke the echoComplexType operation of ComplexService
BasicStruct result = port.echoComplexTypeinput; System.out.printlnInvoked ComplexPortType.echoComplexType. ;
return Invoke went okay Heres the result: + result.getIntValue + , + result.getStringValue + ;
}
Use Cases and Examples 2-25
}
2.5.2 Sample Ant Build File For Building ClientService
The following build.xml file defines tasks to build the client application. The example uses properties to simplify the file.
The following build.xml file uses properties to simplify the file. 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
delete dir={example-output} target
target name=build-service jwsc
srcdir=src destdir={ear-dir}
jws file=exampleswebservicesservice_to_serviceClientServiceImpl.java
type=JAXRPC WLHttpTransport
contextPath=ClientService serviceUri=ClientService portName=ClientServicePort
clientgen type=JAXRPC
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}
2-26 Getting Started With JAX-RPC Web Services for Oracle WebLogic Server
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
3
Developing WebLogic Web Services 3-1
3
Developing WebLogic Web Services
The following sections describe the iterative development process for WebLogic Web Services:
■
Section 3.1, Overview of the WebLogic Web Service Programming Model