How To Make GP API Calls From Java Using Netbeans

How To Make GP API Calls From JAVA (Netbeans)

IDE : Netbeans 6.8(Will work on 6.7+ i hope)

1. First Create A New Java Desktop Application(File -> New Project -> Java -> Java Desktop Application). click next, give it a suitable name (eg Test), click finish.

Adding The WSDL:

1. Goto https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.LBS.Orchestration/WebService_GP_ADP_BizTalk_LBS_Orchestration.asmx?wsdl. Save the page locally.

2. Then edit the 86th & 89th line. The new lines will be –

Line 86 :

<soap:address location=”https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.LBS.Orchestration/WebService_GP_ADP_BizTalk_LBS_Orchestration.asmx”/&gt;

Line 89 :

<soap12:address location=”https://www.aloashbei.com.bd/API/GP.ADP.BizTalk.LBS.Orchestration/WebService_GP_ADP_BizTalk_LBS_Orchestration.asmx”/&gt;

3. Now go to Netbeans. In the Projects explorer(If you can’t find it, press Ctrl+1 or Window->Projects), select the new Project, right click it. Go to New->Other. Select Web Services from categories, select Web Service Client. Press Next. Select Local File: and set the locally saved file as the location. Click Finish

You are done adding the WSDL :-).

2. Design view will come up. Take a label from the Pallete(if you can’t find pallete you can press ctrl+shift+8 or go to Window->Pallete) and put it in the form. Then take a textfield and put it beside it. Now the view should be something like this

3. Change the jLabel1 text to “Please Enter The Mobile No: 017” and jTextField1’s Text to “xxxxxxxx”.

4. Select jTextField1, press right button, goto Events->Action->actionPerformed.

5. Write this code in the actionPerformed function:

WebServiceGPADPBizTalkLBSOrchestration service = new WebServiceGPADPBizTalkLBSOrchestration();

WebServiceGPADPBizTalkLBSOrchestrationSoap port = service.getWebServiceGPADPBizTalkLBSOrchestrationSoap();

LBSRequest req = new LBSRequest();

req.setRegistrationID(“YOUR ID”);

req.setPassword(“YOUR PASS”);

req.setMsisdn(“88017″+jTextField1.getText());

LBSResponse res = port.requestLocation(req);

String response =

“Status = ” + res.getStatus()+”\n”+

“Latitude = ” + res.getLatitude()+”\n”+

“Longitude = ” + res.getLongitude()+”\n”+

“Time = ” + res.getTimestamp()+”\n”;

System.out.print(response);

JOptionPane.showMessageDialog(null, response);

6. Import these classes:

import
com.grameenphone.playground.WebServiceGPADPBizTalkLBSOrchestration;

import
com.grameenphone.playground.WebServiceGPADPBizTalkLBSOrchestrationSoap;

import
lbsresponse.schemas.lbs.biztalk.adp.gp.LBSResponse;

import
lbsrequest.schemas.lbs.biztalk.adp.gp.LBSRequest;

import javax.swing.JOptionPane;

7. Now execute with F6. This should show a prompt for mobile no, write it down, and press Enter.

8. Hopefully after some time you will get the result printed on console and in a dialog.

Happy coding 🙂