Getting Information About a Web Service

Invoking Web Services 6-5

6.2.2 Getting Information About a Web Service

You need to know the name of the Web service and the signature of its operations before you write your Java client application code to invoke an operation. There are a variety of ways to find this information. The best way to get this information is to use the clientgen Ant task to generate the Web service-specific Service files and look at the generated .java files. These files are generated into the directory specified by the destDir attribute, with subdirectories corresponding to either the value of the packageName attribute, or, if this attribute is not specified, to a package based on the targetNamespace of the WSDL. ■ The ServiceName.java source file contains the getPortName methods for getting the Web service port, where ServiceName refers to the name of the Web service and PortName refers to the name of the port. If the Web service was implemented with a JWS file, the name of the Web service is the value of the serviceName attribute of the WebService JWS annotation and the name of the port is the value of the portName attribute of the WLHttpTransport child element of the jws element of the jwsc Ant task. ■ The PortType.java file contains the method signatures that correspond to the public operations of the Web service, where PortType refers to the port type of the Web service. If the Web service was implemented with a JWS file, the port type is the value of the name attribute of the WebService JWS annotation. You can also examine the actual WSDL of the Web service; see Section 3.10, Browsing to the WSDL of the Web Service for details about the WSDL of a deployed WebLogic Web service. The name of the Web service is contained in the service element, as shown in the following excerpt of the TraderService WSDL: service name=TraderService port name=TraderServicePort binding=tns:TraderServiceSoapBinding ... port service The operations defined for this Web service are listed under the corresponding binding element. For example, the following WSDL excerpt shows that the TraderService Web service has two operations, buy and sell for clarity, only relevant parts of the WSDL are shown: binding name=TraderServiceSoapBinding ... ... operation name=sell ... operation operation name=buy operation binding

6.2.3 Writing the Java Client Application Code to Invoke a Web Service