Java Client for Web Services using WebLogic

Discussions

Industry news: Java Client for Web Services using WebLogic

  1. What's the procedure to access a Web Service, given it's WSDL URL, using a Java client in WebLogic 8.1? I have the Java client code but am not sure where to place the Java code (in the WebLogic directory structure).

    What other do I need to do to run the Java client successfully and access the Web Service?

    Thanks in advance for your help.

    Sridhar.
  2. WebLogic Workshop will generate a Java proxy that you may use to communicate with a WebLogic Workshop web service from any Java code. The Java proxy is provided as a JAR file containing the web service-specific proxy classes.

    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).

    Open your web service in WebLogic Workshop, then click the Start button to run the service. The Workshop Test (Test View) browser appears.

    Click the Overview tab.

    Under the Web Service Clients header click Java Proxy

    Save the JAR file to a location that is convenient for your Java application.

    From the Overview tab of Test View, click Proxy Support Jar and save the webserviceclient.jar file to the same location as the proxy JAR file.

    Use the proxy classes as described in the procedure for JSPs above. The following is an example of a Java client using the HelloWorld sample JWS:

    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();
            }
        }
    }

    Compile your source, including the JAR files saved in steps 2 and 3 on your class path.

    Run your Java application, including the two JAR files on your class path.
  3. Thanks for your response. It's very helpful and I understand what needs to be done but still need a little help. I created the client as you suggested, but got some compile errors. Here's what I have done so far:

    I took the sample "HelloWorld" from WebLogic workshop and created the Java proxy (webserviceclient.jar and HelloWorld.jar) that can be used to communicate with the web service. I also created the below client JSP:
    ___________________________________________________________

    <@ page import="weblogic.jws.proxies.*" %>

    <html>
    <body>

    <%
    HelloWorld_Impl proxy = new HelloWorld_Impl();
    HelloWorldSoap soapProxy = proxy.getHelloWorldSoap();
    %>

    Message from the Web Service: <%= soapProxy.Hello() %>

    </body>
    </html>

    ____________________________________________________________

    I put the JSP in my own domain (repairdomain) directory - D:\bea\user_projects\domains\repairdomain\applications\repairApp.

    I put both the jar files in the directory - D:\bea\user_projects\domains\repairdomain\applications\repairApp\WEB-INF\lib

    I added the following to my CLASSPATH -

    D:\bea\user_projects\domains\repairdomain\applications\repairApp\WEB-INF\lib\webserviceclient.jar;

    D:\bea\user_projects\domains\repairdomain\applications\repairApp\WEB-INF\lib\HelloWorld.jar;

    I then ran the JSP from my domain but am getting the following error. Am I missing something? Is this the correct entry to my CLASSPATH? Do I have the JAR files in the correct directory? Is my JSP code correct?

    Thanks again.
    Sridhar.
    ___________________________________________________________

    D:\bea\user_projects\domains\repairdomain\.\myserver\.wlnotdelete\extract\myserver_repairApp_repairApp\jsp_servlet\__webservice.java:126: cannot resolve symbol probably occurred due to an error in /WebService.jsp line 9:

    HelloWorld_Impl proxy = new HelloWorld_Impl();

    D:\bea\user_projects\domains\repairdomain\.\myserver\.wlnotdelete\extract\myserver_repairApp_repairApp\jsp_servlet\__webservice.java:126: cannot resolve symbol probably occurred due to an error in /WebService.jsp line 9:

    HelloWorld_Impl proxy = new HelloWorld_Impl();

    D:\bea\user_projects\domains\repairdomain\.\myserver\.wlnotdelete\extract\myserver_repairApp_repairApp\jsp_servlet\__webservice.java:127: cannot resolve symbol probably occurred due to an error in /WebService.jsp line 10:

    HelloWorldSoap soapProxy = proxy.getHelloWorldSoap();