Webserver generates poorly formatted services.wsdl

I have a Tomcat 7.0 web server that I am using to start a web service. Web Service Framework - CXF 2.5.2.

When testing the web service from the Eclipse Web Service Explorer, everything works as expected. However, when building a Java client from WSDL (using Eclipse) and running it, I get the following error when called super(wsdlLocation, serviceName)

from a 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 message 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"]

. 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">



should usually be quoted. Is this a known bug in one of the frameworks / servers used? What can I do to get around this? And why is there no problem using the Eclipse Web Services Explorer? Is it more fail-safe (as my Firefox seems to be, since it also has no problem to display a graphical representation of the generated wsdl).


source to share

4 answers

Found the problem. I accidentally specified the WSDL endpoint as http://www.example.com:8081/TestWS/services

instead http://www.example.com:8081/TestWS/services/MyTestWS

. So the auto-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 the actual WSDL.



A service list page is an HTML page that lists services and provides links to the corresponding WSDL documents for those services (or WADL documents for rest-based services). This is not a WSDL document. Parsing it as WSDL won't work.



This seems to be a problem / error with CXF service list generation. In the source org.apache.cxf.transport.servlet.servicelist.FormattedServiceListWriter

(around line 52):

    writer.write("<meta http-equiv=content-type content=\"text/html; charset=UTF-8\">");


i.e. the value is http-equiv

not specified. Thus, there is no problem with other tools, because they are more “fault tolerant” - you guessed it.

I'm not sure if the classes com.ctc.wstx.*

look like this is happening and the error is happening. If this is something that you are in control of, the (temporary) job might be to run HTMLTidy on the service listing page?

Might be worth mentioning in the CXF mailing list or raising a bug?



I had the same exception once and it was because in the config file in one place I was missing quotes doule .. example destination-name=closeTaskService

The fix was destination-name="closeTaskService"

, the error was something like below org.jboss.deployment.DeploymentException: Unexpected character 'c' (code 99)

at the beginning of the Expected Quote tag



All Articles