MyEclipse Forums
This thread has been locked & this forum has been archived.
Please post new topics to General Development
View previous topic Printable version Log in to check your private messages View next topic
Author Message
krishna.chaitanya
Post subject: JAX-WS Webservices and Client programming  PostPosted: Apr 11, 2011 - 01:56 PM



Joined: Apr 05, 2011
Posts: 6

Hello.

Reference: http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/2.0/tutorial/doc/JavaWSTutorial.pdf

Section: Building Web Services with JAX-WS.

IDE used: Eclipse

Objective:
------------
I wish to create a client which can interact with a WebService. The code for both of them is listed below. The Android Emulator acts as my client if I'm right; please correct me.

1> I created a new Web Service Project named HelloService. No errors.

2> When it came to Client, I again created a new Web Service Project named SimpleClient.
Then a package named 'simple client', followed by a class named HelloClient. But I get errors. What wrong did I do? In the first place, was it right to create the Client as a Web Service Project.

3> Further, how do I link the Webservice with the Client? They both are two seperate Projects isn't? How can they be made to interact?

__________________________________________________________________

// 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();
}
}
}
-----------------------------------------------------------------
 
 View user's profile Send private message  
Reply with quote Back to top
support-swapna
Post subject: RE: JAX-WS Webservices and Client programming  PostPosted: Apr 12, 2011 - 06:23 AM



Joined: Nov 11, 2010
Posts: 2491

krishna.chaitanya,

The Client is usually a Java project.

Here is the tutorial which details on how to work with JAX-WS in MyEclipse IDE for your referral :
http://www.myeclipseide.com/documentation/quickstarts/blueedition/blue_jaxws/

Hope this helps.

_________________
Swapna
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
krishna.chaitanya
Post subject: Jax-WS Webservices and Client Programming  PostPosted: Apr 12, 2011 - 12:50 PM



Joined: Apr 05, 2011
Posts: 6

Swapna,

My objective is to use the Android phone to connect to a web service. So I've to test the project in the Android emulator, which means that I've to run the project as an android application. Thus I'll try opening both -- the client and the web service programs as android projects. Or, should I open the client alone as an android project. Then the next question is, both of them being separate projects, how do I get them to interact with each other.

Regards,
Krishna.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits