Sample ClientServiceImpl.java JWS File Sample Ant Build File For Building ClientService

2-24 Getting Started With JAX-WS Web Services for Oracle WebLogic Server 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 Application 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 javax.jws.WebService; import javax.jws.WebMethod; import javax.xml.ws.WebServiceRef; Import the BasicStruct data type, generated by clientgen and used by the ComplexService Web Service import examples.webservices.complex.BasicStruct; Import the JAX-WS stubs generated by clientgen for invoking the ComplexService Web service. import examples.webservices.complex.ComplexPortType; import examples.webservices.complex.ComplexService; WebServicename=ClientPortType, serviceName=ClientService, targetNamespace=http:examples.org public class ClientServiceImpl { Use the WebServiceRef annotation to define a reference to the ComplexService Web service. WebServiceRef ComplexService test; WebMethod public String callComplexServiceBasicStruct input, String serviceUrl { Create a port stub to invoke ComplexService ComplexPortType port = test.getComplexPortTypePort; 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=JAXWS WLHttpTransport contextPath=ClientService serviceUri=ClientService portName=ClientServicePort clientgen type=JAXWS 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 2-26 Getting Started With JAX-WS Web Services for Oracle WebLogic Server 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=JAXWS 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 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