Sample WSDL File Sample TemperaturePortType Java Implementation File

2-14 Getting Started With JAX-WS Web Services for Oracle WebLogic Server – The type attribute of the jws element specifies the type of Web services JAX-WS or JAX-RPC. – The WLHttpTransport child element of the jws element of the jwsc Ant task specifies the context path and service URI sections of the URL used to invoke the Web service over the HTTPS transport, as well as the name of the port in the generated WSDL. 10. Execute the build-service target to generate a deployable Web service: prompt ant build-service You can re-run this target if you want to update and then re-build the JWS file. 11. Start the WebLogic Server instance to which the Web service will be deployed. 12. Deploy the Web service, packaged in an Enterprise Application, to WebLogic Server, using either the Administration Console or the wldeploy Ant task. In either case, you deploy the wsdlcEar Enterprise application, located in the output directory. To use the wldeploy Ant task, add the following target to the build.xml file: taskdef name=wldeploy classname=weblogic.ant.taskdefs.management.WLDeploy target name=deploy wldeploy action=deploy name=wsdlcEar source=outputwsdlcEar 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 13. Test that the Web service is deployed correctly by invoking its WSDL in your browser: http:host:porttempTemperatureService?WSDL The context path and service URI section of the preceding URL are specified by the original golden WSDL. Use the hostname and port relevant to your WebLogic Server instance. Note that the deployed and original WSDL files are the same, except for the host and port of the endpoint address. You can use the clean, build-service, undeploy, and deploy targets in the build.xml file to iteratively update, rebuild, undeploy, and redeploy the Web service as part of your development process. To run the Web service, you need to create a client that invokes it. 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.3.1 Sample WSDL File

?xml version=1.0? definitions Use Cases and Examples 2-15 name=TemperatureService targetNamespace=http:www.xmethods.netsdTemperatureService.wsdl xmlns:tns=http:www.xmethods.netsdTemperatureService.wsdl xmlns:xsd=http:www.w3.org2001XMLSchema xmlns:soap=http:schemas.xmlsoap.orgwsdlsoap xmlns=http:schemas.xmlsoap.orgwsdl message name=getTempRequest part name=zip type=xsd:string message message name=getTempResponse part name=return type=xsd:float message portType name=TemperaturePortType operation name=getTemp input message=tns:getTempRequest output message=tns:getTempResponse operation portType binding name=TemperatureBinding type=tns:TemperaturePortType soap:binding style=document transport=http:schemas.xmlsoap.orgsoaphttp operation name=getTemp soap:operation soapAction= input soap:body use=literal namespace=urn:xmethods-Temperature input output soap:body use=literal namespace=urn:xmethods-Temperature output operation binding service name=TemperatureService documentation Returns current temperature in a given U.S. zipcode documentation port name=TemperaturePort binding=tns:TemperatureBinding soap:address location=http:localhost:7001tempTemperatureService port service definitions

2.3.2 Sample TemperaturePortType Java Implementation File

package examples.webservices.wsdlc; import javax.jws.WebService; import javax.xml.ws.BindingType; examples.webservices.wsdlc.TemperatureServiceImpl class implements web service endpoint interface examples.webservices.wsdlc.TemperaturePortType WebService portName=TemperaturePort serviceName=TemperatureService, targetNamespace=http:www.xmethods.netsdTemperatureService.wsdl endpointInterface=examples.webservices.wsdlc.TemperaturePortType 2-16 Getting Started With JAX-WS Web Services for Oracle WebLogic Server wsdlLocation=wsdlsTemperatureServices.wsdl BindingTypevalue=http:schemas.xmlsoap.orgwsdlsoaphttp public class TemperaturePortTypeImpl implements examples.webservices.wsdlc.TemperaturePortType { public TemperaturePortTypeImpl { } public float getTempjava.lang.String zip { return 1.234f; } }

2.3.3 Sample Ant Build File for TemperatureService