• Entries (RSS)
  • Comments (RSS)

Generating a web service proxy client

Posted by | Posted in RAD, WebSphere | Posted on 29-01-2008

Tagged Under : , , , ,

Java web service client applications use a web service proxy client to interact with the Web services APIs. A proxy client allows the developer to invoke the web service APIs as if it was a local method. For generating a web service proxy client, we need the WSDL files that describe the web service interfaces. The WSDL files for business process API is BFMWS.wsdl and for human task API is HTMWS.wsdl. The steps in generating a web service are as follows. (Before following the steps, copy your WSDL files to your workspace or to some location where the WID/RAD can see your WSDL files.

Step 1.
Right click on the web project (from web perspective) and select New -> Other. The select wizard opens. Expand the web service folder and select ‘Web Service Client’.

Web service client selection

Click Next.

Step 2.
From the web service client dialog box, accept the default values (The client proxy type would be Java Proxy, and ‘Create Folders when necessary’ checkbox would be checked and all other check boxes would be unchecked) or select the options that matches your environment.

Web service options page

Click Next.

Step 3.
The web service selection page opens. Click on Browse button. From the opened resource browser window, select the WSDL file. Click OK.

Web service selection page

Click Next.

Step 4.
The client environment configuration window opens. From this page select ‘IBM WebSphere’ as the Web service runtime by clicking the Edit button, if it is not selected already. Select the client type and the client projects.

Client Environment Configuration

Click Next.

Step 5.
The web service proxy client page appears. Accept all the default values.

Web service proxy page

Click Finish.

The web service proxy client will be generated and we can use the generated proxy client and helper classes for invoking the web service from our client application.

Share

Read More

Comments

11 comments posted onGenerating a web service proxy client

  1. [...] Once we got our WSDL files, generate the web service client as mentioned in Generating a web service proxy client. [...]

  2. Hi,

    It helped me in creating WS client however I am wondering how do I test it I dont want to
    test by right clicking on WSDL and checking it :???: . Please tell me how do I write a JavaMethod
    to make a request what all should me parameters ine request and if I need to pass any URL or
    something to make my request. please help.

    Any help will be highly appriciated.

  3. [...] Comments Amit Mittal on Generating a web service proxy clientKathy on Finding the value of a radio buttonHarish on Start a long running business process using [...]

  4. Amit, I have created a small tutorial of how to invoke a web service using web service proxy client and is available at http://www.albeesonline.com/blog/2008/09/15/invoking-a-web-service-using-web-service-proxy-client/. If you have any questions please let me know.

  5. Hi Amit,

    The metjod mentioned here for generating WS stubs is very primitive. Currently we have lot of mechanisms to do the same.

    1) Decide what framework you need for your client (Axis for exmaple)
    2) refer to the axis api for ANT script that will help you create a client
    3) the ant script generallly takes in “testcase” as a parameter which is automatically create you a JUnit test class.

    You can use the JUnit test class for testing your webservice easily.

  6. Hi Albin,
    this document is realy nice,
    i am new to webservises
    using rad 7
    please help me in creating a sample websevice

  7. HI,
    Can you plz let me know how to create a stub less web service client from wsdl…..
    also plz write a test java client as well…

    This will be a great help…
    if u could forward the link to my email will be grt8 help
    java.harpreet@gmail.com

    Thank you

  8. Hi

    As per your given example I am exposing a Java Class as web service and generating the Java Proxy Client. But java class is replaced as Interface after generating the Java Proxy Client. So it giving problem as:

    [6/17/10 14:16:30:708 IST] 00000024 JavaBeanDispa E com.ibm.ws.webservices.engine.dispatchers.java.JavaBeanDispatcher createServiceObject WSWS3422E: Error: Can not instantiate com.web.HelloWorld.
    java.lang.InstantiationException: com.web.HelloWorld
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1263)
    at com.ibm.ws.webservices.engine.dispatchers.java.JavaBeanDispatcher.createServiceObject(JavaBeanDispatcher.java:202)
    at com.ibm.ws.webservices.engine.dispatchers.java.SessionDispatcher.createAndInitServiceObject(SessionDispatcher.java:253)
    at com.ibm.ws.webservices.engine.dispatchers.java.SessionDispatcher.invoke(SessionDispatcher.java:201)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:227)
    at com.ibm.ws.webservices.engine.handlers.jaxrpc.JAXRPCHandler.invoke(JAXRPCHandler.java:152)
    at com.ibm.ws.webservices.engine.handlers.WrappedHandler.invoke(WrappedHandler.java:64)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:227)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:227)
    at com.ibm.ws.webservices.engine.WebServicesEngine.invoke(WebServicesEngine.java:332)
    at com.ibm.ws.webservices.engine.transport.http.WebServicesServlet.doPost(WebServicesServlet.java:736)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at com.ibm.ws.webservices.engine.transport.http.WebServicesServletBase.service(WebServicesServletBase.java:341)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
    at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
    at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
    at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

    [6/17/10 14:16:30:786 IST] 00000024 PivotHandlerW W com.ibm.ws.webservices.engine.PivotHandlerWrapper invoke WSWS3734W: Warning: Exception caught from invocation to com.ibm.ws.webservices.engine.dispatchers.java.JavaBeanDispatcher:
    WebServicesFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
    faultString: WSWS3422E: Error: Can not instantiate com.web.HelloWorld.
    faultActor: null
    faultDetail:

    WSWS3422E: Error: Can not instantiate com.web.HelloWorld.
    at com.ibm.ws.webservices.engine.dispatchers.java.JavaBeanDispatcher.createServiceObject(JavaBeanDispatcher.java:207)
    at com.ibm.ws.webservices.engine.dispatchers.java.SessionDispatcher.createAndInitServiceObject(SessionDispatcher.java:253)
    at com.ibm.ws.webservices.engine.dispatchers.java.SessionDispatcher.invoke(SessionDispatcher.java:201)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:227)
    at com.ibm.ws.webservices.engine.handlers.jaxrpc.JAXRPCHandler.invoke(JAXRPCHandler.java:152)
    at com.ibm.ws.webservices.engine.handlers.WrappedHandler.invoke(WrappedHandler.java:64)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:227)
    at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:227)
    at com.ibm.ws.webservices.engine.WebServicesEngine.invoke(WebServicesEngine.java:332)
    at com.ibm.ws.webservices.engine.transport.http.WebServicesServlet.doPost(WebServicesServlet.java:736)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at com.ibm.ws.webservices.engine.transport.http.WebServicesServletBase.service(WebServicesServletBase.java:341)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
    at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
    at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
    at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
    Caused by: java.lang.InstantiationException: com.web.HelloWorld
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1263)
    at com.ibm.ws.webservices.engine.dispatchers.java.JavaBeanDispatcher.createServiceObject(JavaBeanDispatcher.java:202)
    … 33 more

  9. Hi

    Its working I was doing some wrong.

    Thanks

  10. Hi Mukul, Im experiencing the same problem. I’m clueless on how to fix it. What is your solution?

  11. Hi mukul ,
    i m facing the same problem ..pls help how to solve it

Post a Comment