bea.com | products | dev2dev | support | askBEA |
|
e-docs > WebLogic Server > Programming WebLogic Web Services > Using SOAP 1.2 |
Programming WebLogic Web Services |
The following sections provide information about using SOAP 1.2 as the message transport:
By default, a WebLogic Web Service uses SOAP 1.1 as the message transport when a client application invokes one of its operations. You can, however, use SOAP 1.2 as the message transport 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). Since 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 also use SOAP 1.2 as the message transport:
Specifying SOAP 1.2 for a WebLogic Web Service: Main Steps
The following procedure assumes that you have already implemented and assembled a WebLogic Web Service using the servicegen Ant task, and you want to update the Web Service to use SOAP 1.2 as the message transport.
<servicegen
destEar="c:\myWebService.ear"
warName="myWAR.war"
contextURI="web_services" >
<service
ejbJar="c:\myEJB.jar"
targetNamespace="http://www.bea.com/examples/Trader"
serviceName="TraderService"
serviceURI="/TraderService"
generateTypes="True"
expandMethods="True"
useSoap12="True" >
</service>
</servicegen>
Note: If you prefer not to regenerate your Web Service 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.
See Invoking a Web Service Using SOAP 1.2 for details about writing a Java client application that invokes your Web Service.
Updating the web-services.xml File Manually
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, follow these steps:
<web-service
name="myWebService"
useSoap12="True"
...>
...
</web-service>
Invoking a Web Service Using SOAP 1.2
When writing your client appliction 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 of your Web Service 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() );
}
}