You are on page 1of 2

How to call SOAP webservice On Netbeans IDE

Posted on http://m-shaheen.blogspot.com

In these below lines I describe briefly how to add SOAP web service call using
Netbeans 6.5 IDE built in wizards for both J2ME and J2EE/J2SE platforms:

J2ME platform

1. Right click the project item : New>MIDP>Java ME Web Service Client

2. Press Next

3. enter WSDL file URL

4. Press Finish

This will create SOAP stub classes for that web service

5. in the midlet code insatiate the web service stup class (not use the interface)

Sample code:

eis_wsbackendService_Stub backend = new


eis_wsbackendService_Stub();

backend._setProperty(

eis_wsbackendService_Stub.SESSION_MAINTAIN_PROPERTY,

new Boolean(true)

);

try {

Integer userID = new Integer(10245);

aa = backend.getAccounts(userID);

} catch (RemoteException ex) {

ex.printStackTrace();

}
J2EE/J2SE
1. Right click the project item : New>WebServiceClient

2. enter WSDL URL

this will create the SOAP stub classes for the referenced Web service

3. Drag and drop the web service reference from the IDE this will create the
following code :

try {

// Call Web Service Operation

com.galaxy.test.eis.ws.EisWsbackendService service = new


com.galaxy.test.eis.ws.EisWsbackendService();

com.galaxy.test.eis.ws.EisWsbackend port =
service.getEisWsbackendPort();

// TODO initialize WS operation arguments here

Integer userID = 10245;

// TODO process result here

java.lang.String result = port.getAccounts(userID);

System.out.println("Result = "+result);

} catch (Exception ex) {

ex.printStackTrace();

You might also like