Web-service Call Using Oracle ADF Mobile Framework (Android)
Writing web service
I have written a simple webservice which will take String as parameter and return result in the form of String itself.
package samplewebservice;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService
public class SampleService {
public SampleService() {
super();
}
@WebMethod
public String sayHello(@WebParam(name="name") String name){
return "Hello, "+name+" !!!!!!!!!!!!!!!!!!!";
}
}
Deploying Web-service
Once service developed you have to deploy that service on some server. I am using weblogic server to deploy HelloService(You can select any server). Start your server.
- Select Application as Mobile Application(ADF) template
- Provide application name like WebServiceCall
- Click on finished. it will create 2 project in application ApplicationController and ViewController
- Select ApplicationController and created webservice datacontrol.
- Provide WSDL with your system IP address because localhost and 127.0.0.1 doen't work for mobile.
- Enter webservice url and datacontrol name
- Click on next then select method and click on finished.
- Now Select the ViewController Project and Right Click and go on new.
- Select ADF mobile from the Client Tire from category
- Provide the feature name like WebserviceCall and click on Ok button. It will created a folder with name of WebServiceCall inside public_html.
- An Entry with the feature name will added to adfm-feature.xml file
- Select the feature id from feature table
- Go to content tab
- Click on the + icon of file
- Select the taskflow it will ask you to enter name for task flow enter name and same taskflow will created.
- Now select the WebserviceCall feature folder and create amx page with name of LoginPage.amx
- Drag and drop that amx to taskflow as default activity
- Create responsePage.amx for showing service response
- Define the ControlFlow as ShowResult
- Expand created data control
- Drag and drop name from parameter to amx page as inputtext.
- Provide label as Enter your name
- Surround it with panelFormLayout
- Drag Drop sayHello method as button screen
- Open responsePage.amx and dragdrop String as outputtext with label.
Deploying Application to Android simulator
- Select the Application
- Goto properties and define deployment profile
- Start your AVD
Please follow my previous post to setup AVD click here
Running Application
- Open Application
- Enter your name
Download MobileADFApplication and WebserviceApp
Note : Replace the IP in the downloaded files with your machine IP address