Hello.
Reference: http://download.oracle.com/docs/cd/...ices/docs/2.0/tutorial/doc/JavaWSTutorial.pdf
Section: Building Web Services with JAX-WS.
IDE used: MyEclipse
Objective:
------------
I want the Android Emulator(client) to connect to a web service. So should I open two separate Android projects -- named Client and WS?
I cannot open them as new Web Service Projects, knowing that they cannot be run on the Android Emulator. Or, should I open the Client as an Android Project and the WS as a Web Service Project. And if I do, how can I get the two projects to interact. Because after all, the client and the web service are running on the same machine.
I'm considering a sample program as under:
__________________________________________________________________
// Webservice
------------------------------------------------------------
package helloservice.endpoint;
import javax.jws.WebService; // error
@WebService() // error
public class Hello {
private String message = new String("Hello, ");
public void Hello() {}
@WebMethod() // error
public String sayHello(String name) {
return message + name + ".";
}
}
--------------------------------------------------------------
// Client
--------------------------------------------------------------
package simpleclient;
import javax.xml.ws.WebServiceRef;
import helloservice.endpoint.HelloService;
import helloservice.endpoint.Hello;
public class HelloClient {
@WebServiceRef(wsdlLocation="http://localhost:8080/helloservice/hello?wsdl")
static HelloService service;
public static void main(String[] args) {
try {
HelloClient client = new HelloClient();
client.doTest(args);
} catch(Exception e) {
e.printStackTrace();
}
}
public void doTest(String[] args) {
try {
System.out.println("Retrieving the port from the following service: " + service);
Hello port = service.getHelloPort();
System.out.println("Invoking the sayHello operation on the port.");
String name;
if (args.length > 0) {
name = args[0];
} else {
name = "No Name";
}
String response = port.sayHello(name);
System.out.println(response);
} catch(Exception e) {
e.printStackTrace();
}
}
}
-----------------------------------------------------------------
Reference: http://download.oracle.com/docs/cd/...ices/docs/2.0/tutorial/doc/JavaWSTutorial.pdf
Section: Building Web Services with JAX-WS.
IDE used: MyEclipse
Objective:
------------
I want the Android Emulator(client) to connect to a web service. So should I open two separate Android projects -- named Client and WS?
I cannot open them as new Web Service Projects, knowing that they cannot be run on the Android Emulator. Or, should I open the Client as an Android Project and the WS as a Web Service Project. And if I do, how can I get the two projects to interact. Because after all, the client and the web service are running on the same machine.
I'm considering a sample program as under:
__________________________________________________________________
// Webservice
------------------------------------------------------------
package helloservice.endpoint;
import javax.jws.WebService; // error
@WebService() // error
public class Hello {
private String message = new String("Hello, ");
public void Hello() {}
@WebMethod() // error
public String sayHello(String name) {
return message + name + ".";
}
}
--------------------------------------------------------------
// Client
--------------------------------------------------------------
package simpleclient;
import javax.xml.ws.WebServiceRef;
import helloservice.endpoint.HelloService;
import helloservice.endpoint.Hello;
public class HelloClient {
@WebServiceRef(wsdlLocation="http://localhost:8080/helloservice/hello?wsdl")
static HelloService service;
public static void main(String[] args) {
try {
HelloClient client = new HelloClient();
client.doTest(args);
} catch(Exception e) {
e.printStackTrace();
}
}
public void doTest(String[] args) {
try {
System.out.println("Retrieving the port from the following service: " + service);
Hello port = service.getHelloPort();
System.out.println("Invoking the sayHello operation on the port.");
String name;
if (args.length > 0) {
name = args[0];
} else {
name = "No Name";
}
String response = port.sayHello(name);
System.out.println(response);
} catch(Exception e) {
e.printStackTrace();
}
}
}
-----------------------------------------------------------------