In this post I describe the conversion of examples of chapter 11, which deals with EJB 3 Web Services, from Glassfish to Weblogic 10.3. Apart from one minor exception described below no source code changes were required. The only modifications required were to the application server specific ant tasks which generate various web service artifacts. These ant tasks were all defined in the build.xml file.
The equivalent of the Glassfish wsgen tool in Weblogic is the jwsc ant task. jwsc takes as input a Java class file with embedded web service annotations and generates all the artifacts required to create a web service. In Glassfish explicit use of wsgen is optional as web service artifacts are generated as deployment time if they have not already been created by wsgen. In Weblogic we do need to explicitly invoke jwsc before deployment.
The wsdl file created by jwsc creates a "REPLACE_WITH_ACTUAL_URL" placeholder for the web service URL. Consequently we need to edit the wsdl file and specify the actual URL. For example in lab1 we must edit the build\webservice\ArithmeticService.wsdl file from:
<service name="ArithmeticService"> <port name="ArithmeticPort" binding="tns:ArithmeticPortBinding"> <soap:address location="REPLACE_WITH_ACTUAL_URL"/> </port> </service> to: <service name="ArithmeticService"> <port name="ArithmeticPort" binding="tns:ArithmeticPortBinding"> <soap:address location="http://localhost:7001/Arithmetic/Arithmetic"/> </port> </service>
The equivalent of the Glassfish wsimport tool in Weblogic is the clientgen ant task. clientgen generates from an existing wsdl file the client artifacts that client applications use to invoke Weblogic and non-Weblogic web services.
In Weblogic we cannot use @WebServiceRef annotation to define a reference to a Web Service from a stand-alone Java client. In Weblogic @WebServiceRef is only used to invoke a web service from another web service. Consequently in lab1 the source code for WebServiceClient was changed from public class WebServiceClient { @WebServiceRef(wsdlLocation="http://localhost:8080/arithmetic-webservice/ArithmeticService?WSDL") static ArithmeticService service; public static void main(String[] args) { try { ... to public class WebServiceClient { public static void main(String[] args) { try { ArithmeticService service = new ArithmeticService(); ... It was not possible to have a Weblogic version of lab2. The glassfish version of lab2 has a MathematicsImpl implementation of the Mathematics interface: @WebService(endpointInterface = "endpoint.Mathematics") public class MathematicsImpl implements Mathematics { ... We use the endpointInterface attribute to specify the interface. However in Weblogic we use the endpointInterface attribute to specify the service endpoint interface generated by the wsdlc ant task. The wsdlc ant task takes as input wsdl file and generates web service artifacts including the Java service endpoint interface (this is known as the top-down approach) . In the next post I'll describe the conversion of chapter 12 examples which demonstrate EJB 3 security. .
The 1.48 server version had (among other hidden features) the ability to extend itself by modifying a dispatcher and adding a handler for different types of messages.
Posted by: winamax poker | March 29, 2011 at 06:00 AM