Programming WebLogic Web Services
|
|
The following sections provide information about using SOAP 1.2 as the message format:
By default, a WebLogic Web Service uses SOAP 1.1 as the message format when a client application invokes one of its operations. You can, however, use SOAP 1.2 as the message format by updating the web-services.xml file and specifying a particular attribute in clientgen when you generate the client stubs.
Warning: BEA's SOAP 1.2 implementation is based on the W3C Working Draft specification (June 26, 2002). Because this specification is not yet a W3C Recommendation, BEA's current implementation is subject to change. BEA highly recommends that you use the SOAP 1.2 feature included in this version of WebLogic Server in a development environment only.
When a WebLogic Web Service is configured to use SOAP 1.2 as the message format:
clientgen Ant task, when generating the Web-service specific client JAR file for the Web Service, creates a Service implementation that contains two getPort() methods, one for SOAP 1.1 and another for SOAP 1.2.
The following procedure assumes that you are familiar with the servicegen Ant task, and you want to update the Web Service to use SOAP 1.2 as the message format. For an example of using servicegen, see Creating a WebLogic Web Service: A Simple Example.
<servicegen
destEar="ears/myWebService.ear"
warName="myWAR.war"
contextURI="web_services" >
<service
ejbJar="jars/myEJB.jar"
targetNamespace="http://www.bea.com/examples/Trader"
serviceName="TraderService"
serviceURI="/TraderService"
generateTypes="True"
expandMethods="True"
useSOAP12="True" >
</service>
</servicegen>
Note: If you are not using servicegen, you can update the web-services.xml file of your WebLogic Web Service manually. For details, see Updating the web-services.xml File Manually.
For general details about the servicegen Ant task, see Creating the Build File That Specifies the servicegen Ant Task.
Because the WSDL of the Web Service has been updated to include an additional port with a SOAP 1.2 binding, the clientgen Ant task automatically creates new stubs that contains these SOAP 1.2-specific getPort() methods.
For details, see Generating the Client JAR File by Running the clientgen Ant Task.
See Invoking a Web Service Using SOAP 1.2 for details about writing a Java client application that invokes your Web Service.
The web-services.xml file is located in the WEB-INF directory of the Web application of the Web Services EAR file. See The Web Service EAR File Package for more information on locating the file.
To update the web-services.xml file to specify SOAP 1.2:
useSOAP12="True" attribute to the <web-service> element that describes your Web Service. For example:<web-service
name="myWebService"
useSOAP12="True"...>
...
</web-service>
When writing your client application to invoke the SOAP 1.2-enabled WebLogic Web Service, you first use the clientgen Ant task to generate the Web Service-specific client JAR file that contains the generated stubs, as usual. The clientgen Ant task in this case generates a JAX-RPC Service implementation that contains two getPort() methods: the standard one for SOAP 1.1, called getServiceNamePort(), and a second one for SOAP 1.2, called getServiceNamePortSoap12(), where ServiceName refers to the name of your Web Service. These two getPort() methods correspond to the two port definitions in the generated WSDL of the Web Service, as described in Overview of Using SOAP 1.2.
The following example of a simple client application shows how to invoke the helloWorld operation of the MyService Web Service using both SOAP 1.1 (via the getMyservicePort() method) and SOAP 1.2 (via the getMyServicePortSoap12() method):
import java.io.IOException;
public class Main{
public static void main( String[] args ) throws Exception{
MyService service = new MyService_Impl();
MyServicePort port = service.getMyServicePort();
System.out.println( port.helloWorld() );
port = service.getMyServicePortSoap12();
System.out.println( port.helloWorld() );
}
}
|
|
|