1

I am following the Java EE 6 tutorial and trying to set-up a basic client for a web service. I am generating the required code using Eclipse.

Method:

  1. Create a new Java project
  2. Start the [Web Service Client] wizard
  3. Provide the [Service Definition] and select [Develop Client]

This generates the code, but I get the following errors (repeated multiple times):

endpoint.Hello cannot be resolved to a type HelloProxy.java /com.examples.helloclientapp/src/endpoint line

Hello cannot be resolved to a type HelloProxy.java /com.examples.helloclientapp/src/endpoint

This is the code for the webservice I am using (which works and I can access the wsdl):

package endpoint;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public class Hello {

    private String message = new String("Hello, ");

    public void Hello() {
    }

    @WebMethod
    public String sayHello(String name) {
        return message + name + ".";
    }

}

The generated code that is giving me a problem is the HelloProxy. It seems to be missing the Hello class (this did not get generated):

package endpoint;

public class HelloProxy implements endpoint.Hello {
  private String _endpoint = null;

  // This was not generated
  private endpoint.Hello hello = null;
  
  public HelloProxy() {
    _initHelloProxy();
  }
  
  public HelloProxy(String endpoint) {
    _endpoint = endpoint;
    _initHelloProxy();
  }
  
  private void _initHelloProxy() {
    try {
      hello = (new endpoint.HelloServiceLocator()).getHelloPort();
      if (hello != null) {
        if (_endpoint != null)
          ((javax.xml.rpc.Stub)hello)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
        else
          _endpoint = (String)((javax.xml.rpc.Stub)hello)._getProperty("javax.xml.rpc.service.endpoint.address");
      }
      
    }
    catch (javax.xml.rpc.ServiceException serviceException) {}
  }
  
  public String getEndpoint() {
    return _endpoint;
  }
  
  public void setEndpoint(String endpoint) {
    _endpoint = endpoint;
    if (hello != null)
      ((javax.xml.rpc.Stub)hello)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
    
  }
  
  public endpoint.Hello getHello() {
    if (hello == null)
      _initHelloProxy();
    return hello;
  }
  
  
}

The other files that were generated are (If needed I can give the contents):

  • Hello_PortType.java
  • HelloPortBindingStub.java
  • HelloService.java
  • HelloServiceLocator.java

Is there something wrong with the webservice that is causing the Hello class to not be generated?

Community
  • 1
  • 1
Paul Jackson
  • 11
  • 1
  • 2
  • Despite of the errors it looks fine to me. Have you already tried to call your WS from client code? Please show your client code?. Cheers! – SimonSez Mar 29 '12 at 09:17
  • @SimonSez I have tested the web service with the eclipse Web Service Explorer and it seems to work correctly – Paul Jackson Mar 29 '12 at 14:40
  • I can't see anything wrong with your files. Try to generate a simple client which uses your generated files (see [this](http://stackoverflow.com/questions/9663420/how-to-call-a-web-service-using-javaee/9693919#9693919), you'll just need the code part) and see if it works. Cheers! – SimonSez Mar 29 '12 at 15:24

0 Answers0