我创建了两项服务public String add(int x, int y)
和public String sub(int x, int y)
。现在,这些服务的定义如下:
package com.webservice.calc;
import javax.jws.WebService;;
@WebService
public class Calculator {
String s;
public String add(int x, int y)
{
s = "Sum of "+x+" and "+y+" is : "+(x+y);
return s;
}
public String sub(int x, int y)
{
s = "Sum of "+x+" and "+y+" is : "+(x-y);
return s;
}
}
我没有写差异,而是在sub
服务中写了 Sum 。
然后我用 wsgen 工具生成wsdl文件并使用Endpoint发布者,我发布了它。
然后,我创建了另一个项目(Web Service Consumer)并使用 wsimport 导入了Web服务。
代码很好。但是,现在我想将 Sum 更改为差异。
我更改了原始代码中的代码,然后使用 wsgen ,然后重新发布(这里出现了错误:
Exception in thread "main" Server Runtime Error: Server Runtime Error: java.net.BindException: Address already in use: bind
at com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(Unknown Source)
at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(Unknown Source)
at javax.xml.ws.Endpoint.publish(Unknown Source)
at com.webservice.calc.endpoint.CalcEndpointPublisher.main(CalcEndpointPublisher.java:12)
Caused by: Server Runtime Error: java.net.BindException: Address already in use: bind
at com.sun.xml.internal.ws.transport.http.server.ServerMgr.createContext(Unknown Source)
... 5 more
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at sun.net.httpserver.ServerImpl.<init>(Unknown Source)
at sun.net.httpserver.HttpServerImpl.<init>(Unknown Source)
at sun.net.httpserver.DefaultHttpServerProvider.createHttpServer(Unknown Source)
at com.sun.net.httpserver.HttpServer.create(Unknown Source)
... 6 more
)然后再次导入它。但没有变化。这是什么问题?