Exception in thread "main" javax.xml.ws.WebServiceException: WSDL file:/E:/workspace/A06_wsdl/bin/META-INF/wsdl/mywsdl.wsdl has the following services [{http://www.example.org/mywsdl/}MyServcieImplService] but not {http://www.example.org/mywsdl/}MyServiceImplService. Maybe you forgot to specify a serviceName and/or targetNamespace in @WebService/@WebServiceProvider?
at com.sun.xml.internal.ws.server.EndpointFactory.verifyPrimaryWSDL(EndpointFactory.java:664)
at com.sun.xml.internal.ws.server.EndpointFactory.create(EndpointFactory.java:221)
at com.sun.xml.internal.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:144)
at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:563)
at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:545)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:308)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:231)
at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:126)
at javax.xml.ws.Endpoint.publish(Endpoint.java:240)
at org.example.mywsdl.MyServer.main(MyServer.java:7)
解决方式:
参考:
* @see ----------------------------------------------------------------------------------------------------------
* @see 手工编写SIB
* @see 1)最好显式的让SIB和SEI的targetNamespace相同
* @see 2)当指定serviceName值时,其值应为wsdl文件中的<wsdl:service name="CalculatorServiceImpl">标签的name值
* @see 3)不指定serviceName值时,wsdl中的<wsdl:service name="">则应为SIBService,如CalculatorServiceImplService
* @see 否则在启动WebService服务时,会报告下面的异常
* @see Exception in thread "main" javax.xml.ws.WebServiceException:
* @see wsdl file:/F:/Tool/Code/JavaSE/ws_contractFirst/bin/META-INF/wsdl/myCalculator.wsdl
* @see has the following services [{http://blog.csdn.net/jadyer}CalculatorServiceImpl]
* @see but not {http://blog.csdn.net/jadyer}CalculatorServiceImplService
* @see Maybe you forgot to specify a service name in @WebService/@WebServiceProvider?
* @see ----------------------------------------------------------------------------------------------------------
我的问题原因是wsdl中:
<wsdl:service name="MyServcieImplService">
MyServcie单词写反了。
而手动编写的实现类单词是正确的。
@WebService(endpointInterface="org.example.mywsdl.IMyService",
targetNamespace="http://www.example.org/mywsdl/",
wsdlLocation="META-INF/wsdl/mywsdl.wsdl")
public class MyServiceImpl implements IMyService {
解决:修改单词,重新使用wsimport生成代码,只留service接口。