Question

The problem is: JAX-WS service have public constructor with some preparatory operations (read config etc.) This service deploys on Tomcat 7 successful and i can call its operations, but its constructor not calls.

Question: how to call constructor of JAX-WS service or how to solve this problem in other optimal way?

Code:

Service:

@WebService(serviceName="myServiceName" endpointInterface="pack.myServiceInterface")
public class myService implements myServiceInterface
{
    // constructor
    public void myService() // never calls !!!
    {
        // some actions (read config etc.)
    }

    // method for clients call
    public int someMethod()
    {
        ...
    }
}

Client:

...
Service svc = Service.create(urlWsdl, new QName(namespaceSvc, "myServiceName"));
port = svc.getPort(new QName(namespaceSvc, portSvc), MyServiceInterface.class);
int a = port.someMethod();
...
Was it helpful?

Solution

// constructor
    public void myService() // never calls !!!
    {
        // some act

ions (read config etc.) }

Because It's not a constructor of your class. you can not use return type in constructor not even void.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top