Trying to call web service (and failing)
Hi All,
I'm new to Java. I'm using JDK 6 update 18, Netbeans 6.8 and Glassfish v3 to try to create a project that calls a web service. My intention is to create a web service proxy project. ie many web services to call one other webservice. The Java layer should be very thin and literally just pass messages back and forth between caller and web service client.
In order to simulate this I have created a web service project. This web service returns a string, real basic. I build, deploy and test this and it works fine. Yay.
I then created another project. I create a web service client pointing to the WSDL that GlassFish tells me is available, (this can be reached through the browser).
In this project I also create a web service. I drag the operation from the web service client, (Arun Gupta stylee) into the new operation in the web service and it creates the necessary code etc...
I build, deploy and run this only to find that I cannot test the web service. Why?
Code :
WARNING: Servlet web service endpoint 'NewWebClient' failure
java.lang.IllegalArgumentException: class org.glassfish.webservices.JAXWSServlet has neither @WebService nor @WebServiceProvider annotation
Code :
@WebService()
public class NewWebClient {
@WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_8080/TestService/WebService1Service.wsdl")
private WebService1Service service;
/**
* Web service operation
*/
@WebMethod(operationName = "clienttest")
public String clienttest() {
//TODO write your implementation code here:
try { // Call Web Service Operation
server1.WebService1 port = service.getWebService1Port();
// TODO process result here
java.lang.String result = port.helloworldservice();
//System.out.println("Result = "+result);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
return "";
My code is above. (relevant bits anyway)
Can anyone tell my what I might be doing wrong? I've not really done anything special, I have a few plugins installed, those I thought I might muck about with (REST webservices etc) but other than that the installation should be standard and like I said I don't get any build errors, just the loads of stack trace info about these missing annotations.
Any help would be great,
Ta Jim
Re: Trying to call web service (and failing)
Ok, so it turns out that the example that I followed was wrong.
The solution?
Once I created the Web Service Client (WSC), I then created a boggo standard Java class in a different package to the Web Service. I dragged the WSC onto the class (instead of the WS), I then use this class in my Web Service instead of directly using the WSC. Weird? I thought so, works now though :)
Re: Trying to call web service (and failing)
Had exactly the same problem .Your solution worked like a charm.
Thanks a lot!