I have a Tomcat 7.0 web server which I use to run a web service on it. The web service framework is CXF 2.5.2.
When testing the web service from the Eclipse Web Service Explorer everything works as supposed. However, when generating a Java Client from the WSDL (using Eclipse) and running it, I get the following error when calling super(wsdlLocation, serviceName)
from the Service implementation:
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
The interesting part should be the 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"]
message. When inspecting the generated services.wsdl, I found, that the problem is in the meta part:
<meta http-equiv=content-type content="text/html; charset=UTF-8">
content-type
should be normally wrapped into quotes. Is this a known bug in one of the used frameworks/servers? What can I do to work around this? And why is there no problem when using the Eclipse Web Services Explorer? Is it more fault-tolerant (as my Firefox seems to be as it also doesn't have any problems to display a graphical representation of the generated wsdl).
Found the problem. I accidentally specified the WSDL endpoint as http://www.example.com:8081/TestWS/services
instead of http://www.example.com:8081/TestWS/services/MyTestWS
. So the automatically generated client tried to fetch the WSDL from http://www.example.com:8081/TestWS/services?wsdl
which returns an HTML page, instead of http://www.example.com:8081/TestWS/services/MyTestWS?wsdl
which returns an actual WSDL.