Featured Posts

Integrating GlassFish Application server with Apache... A typical production topology for GlassFish will be a front ending GlassFish with Apache for serving the static files. To integrate GlassFish Application Server with Apache web server follow the below...

Readmore

Some Java, JEE and WebSphere stuffs Rss

Web service client with basic authentication

Posted by Albin Joseph | Posted in Web service | Posted on 23-06-2009

2

Configuring a web service client for basic authentication

How do we pass the username and password to a web service which is protected by basic authentication? The generated proxy client has no methods for setting the username and password.

The solution is to set the username and password inside the generated proxy client. To do this edits your proxy java file and set the username and password properties. The properties are javax.xml.rpc.Stub.USERNAME_PROPERTY and javax.xml.rpc.Stub.PASSWORD_PROPERTY. I did it inside my _initXXX method of proxy client. For eg: my code looked like the following

if (test_Request != null) {
	((javax.xml.rpc.Stub)test_Request)._setProperty(Stub.USERNAME_PROPERTY, "username");	
	((javax.xml.rpc.Stub)test_Request)._setProperty(Stub.PASSWORD_PROPERTY,"password");	
}

If you set any other property name you will get an exception

Exception in thread "main" javax.xml.rpc.JAXRPCException: WSWS3212E: Error: Property name javax.xml.rpc.Stub.XXX not supported.
	at com.ibm.ws.webservices.engine.client.Stub._setProperty(Stub.java:541)

Invoking a web service using web service proxy client

Posted by Albin Joseph | Posted in Web service, WebSphere | Posted on 15-09-2008

33

Invoking a web service using web service proxy client

Yesterday I got a comment on my post “Generating a web service proxy client” asking how do we invoke or test this web service using the webservice proxy client. So I thought of writing a post of how to use the generated proxy client to call a webservice. Here I am going to create a simple JSP file that is going to use the webservice proxy client to call or invoke the Hello World web service running in WebSphere.

Before you start, please make sure that you have generated the web service client as mentioned in Generate web service proxy client in java. If you do not have the Hello World web service running in your server, follow the tutorial at Creating a Hello World web service using RAD.

While generating the webservice proxy client I generated the Java files using no wrapped style.

One we have the java proxy files generated we can see some files named XXXProxy.java, XXX.java, XXXService.java, XXXServiceInformation.java, XXXServiceLocator.java etc in our workspace. Now create a new jsp file for calling the web service. Add the following code to invoke the Hello World webservice using our web service proxy client.

	com.test.HelloWorldProxy proxy = new com.test.HelloWorldProxy();
        proxy.setEndpoint("http://localhost:9081/WSTest/services/HelloWorld");
        String name = proxy.sayHello("Albin Joseph");
 
        System.out.println(name);

If everything works fine, we would see a ‘Hello Albin Joseph’ as the output in your console.

Our Hello World service was exposing a sayHello method as a webservice. The HelloWorldProxy class is the proxy client class for our webservice. If we are not setting the end point url (the url of the webservice), our proxy client would take the default one present in the wsdl file.

Generating a web service proxy client

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

7

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.

IWAB0639E Error when generating web service client

Posted by Albin Joseph | Posted in RAD, WebSphere | Posted on 25-01-2008

4

Today when I tried to generate a web service client for Business Flow Manager API (WSDL files are BFMIF.wsdl, BFMWS.wsdl), WebSphere Integration Developer started giving me an error message and no web service client files are generated. :-( . The error message is as follows.

IWAB0639E Error in generating Java files and deployment descritpors from WSDL file
   java.io.IOException: WSWS3205E: Error: Type {http://www.w3.org/2001/XMLSchema}anySimpleType is referenced but not defined.
   at com.ibm.ws.webservices.wsdl.symbolTable.SymbolTable.checkForUndefined(SymbolTable.java:656)
   at com.ibm.ws.webservices.wsdl.symbolTable.SymbolTable.firstPass(SymbolTable.java:528)
   at com.ibm.ws.webservices.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:500)
   at com.ibm.ws.webservices.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:472)
   at com.ibm.ws.webservices.wsdl.Parser$WSDLRunnable.run(Parser.java:293)
   at java.lang.Thread.run(Thread.java:816)

I have generated these WSDLs from the admin console of WebSphere Application Server. I don’t know what the root cause of this problem is. I had done a search on this error message and I could see some people are telling this as a problem with SOAP version, RAD is using. However I found out the solution for this problem.

In the web service client generation wizard, in Client Environment Configuration select ‘IBM WebSphere’ as the Web service runtime. Now you will be able to generate the web service client without any problems.