java – Webserver生成格式错误的services.wsdl

我有一个Tomcat 7.0 Web服务器,我用它来运行Web服务. Web服务框架是CXF 2.5.2.

Eclipse Web Service Explorer测试Web服务时,一切都按预期工作.但是,当从WSDL(使用Eclipse)生成Java客户端并运行它时,从Service实现调用super(wsdlLocation,serviceName)时会出现以下错误:

Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:150)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:91)
at javax.xml.ws.Service.<init>(Service.java:77)
at test.Test_Service.<init>(Test_Service.java:43)
at test.Test_TestSOAP_Client.main(Test_TestSOAP_Client.java:47)

Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:94)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:148)
... 4 more

Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'c' (code 99) in start tag Expected a quote at [row,col,system-id]: [1,208,"http://www.example.com:8081/TestWS/services?wsdl"]
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:240)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:191)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
... 6 more

Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'c' (code 99) in start tag Expected a quote at [row,col,system-id]: [1,208,"http://www.example.com:8081/TestWS/services?wsdl"]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:3005)
at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2926)
at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2802)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1050)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1080)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:974)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:901)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:231)
... 8 more

有趣的部分应该是开始标记中的意外字符’c'(代码99)预期引用
 在[row,col,system-id]:[1,208,“http://www.example.com:8081/TestWS/services?wsdl”]消息.在检查生成的services.wsdl时,我发现问题出在meta部分:

<meta http-equiv=content-type content="text/html; charset=UTF-8">

content-type通常应该包含在引号中.这是一个已使用的框架/服务器中的已知错误吗?我该怎么做才能解决这个问题?为什么使用Eclipse Web Services Explorer时没有问题?它是否更容错(因为我的Firefox似乎是因为它也没有任何问题来显示生成的wsdl的图形表示).

解决方法:

服务列表页面是一个HTML页面,列出服务并提供指向这些服务的相应WSDL文档的链接(或基于其余服务的WADL文档).它不是WSDL文档.将其解析为WSDL是行不通的.

上一篇:来看下,C# WebService WSDL自动生成代码,数组参数的BUG。。。ArrayOfString


下一篇:Apache CXF :: wsdl2java忽略公共条目的目录配置