Using the Java proxy for a web service requires different steps depending on whether you use it from within WebLogic Server (as in a JSP or servlet) or from outside WebLogic Server (as in a standalone Java application).
Note:You can also call a web service from a page flow via a Web Service control. This approach is simpler than using the proxy.
Note: You should not use a Web Service control to invoke a web service that resides in the same application. Invoking a web service via a Web Service control means marshalling the method parameters into a SOAP message on the calling end and unmarshalling the SOAP message on the receiving end, then again for the method return value. This is very inefficient when the invocation is local. You would usually be tempted to invoke a local web service if the called web service includes business logic you want to access.
In general, you should place business logic in custom Java controls instead of in web services. This allows you to access the business logic from various contexts in the application (web services, other controls, page flows) without incurring the cost of data marshalling and unmarshalling. Web Service controls should only be used to invoke web services that are truly external to your application.
To Use the Java Proxy from a JSP
If you want to use the web service proxy JAR from more than one project in your application, you can add it to the Libraries folder at the root of your application. Saving the JAR directly to the APP-INF/lib directory at the root of your application will automatically add the JAR file to the Libraries folder.
<%@ page import="weblogic.jws.proxies.*" %>
<% HelloWorld_Impl proxy = new HelloWorld_Impl(); %>
<% HelloWorldSoap soapProxy = proxy.getHelloWorldSoap(); %>
<%= soapProxy.Hello() %>
Note that you will need to download a new copy of the proxy if you change any of the signatures of the web service methods or callbacks.
For an example that demonstrates use of a web service Java proxy from a JSP page, see Java Client Samples.
To Use the Java Proxy from a Java Project in WebLogic Workshop
To Use the Java Proxy in a Separate Java Application
import weblogic.jws.proxies.*; public class Main { public static void main(String[] args) { try { HelloWorld_Impl proxy = new HelloWorld_Impl(); HelloWorldSoap soapProxy = proxy.getHelloWorldSoap(); System.out.println(soapProxy.Hello()); } catch (Exception e) { e.printStackTrace(); } } }
For examples that demonstrates use of a web service Java proxy from Java clients, see Java Client Samples.
WebLogic Workshop uses WebLogic Server's clientgen tool to generate the Java proxy for a web service, based on the web service's WSDL file. You may use the clientgen tool directly if you wish to customize the generated Java proxy. To learn more about clientgen, see the documentation for clientgen on http://www.oracle.com/technology/documentation/index.html.
The clientgen tool accepts several command line parameters. The only parameter set by WebLogic Workshop when generating a Java proxy from Test View is the packageName parameter, which is always set to weblogic.jws.proxies.
None.