![](/img/trans.png)
[英]JAX-WS Service giving FileNotFoundException while using default constructor?
[英]Constructor of JAX-WS service not calling
問題是:JAX-WS服務具有一些准備操作(讀取配置等)的公共構造函數。該服務成功部署在Tomcat 7上,我可以調用其操作,但不能調用其構造函數。
問題:如何調用JAX-WS服務的構造函數或如何以其他最佳方式解決此問題?
碼:
服務:
@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()
{
...
}
}
客戶:
...
Service svc = Service.create(urlWsdl, new QName(namespaceSvc, "myServiceName"));
port = svc.getPort(new QName(namespaceSvc, portSvc), MyServiceInterface.class);
int a = port.someMethod();
...
// constructor
public void myService() // never calls !!!
{
// some act
離子(讀取配置等)}
因為它不是您的類的構造函數。 您不能在構造函數中使用返回類型,甚至不能使用void。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.