GeeCON Prague 2014*
The moose likes Web Services and the fly likes Unexpected character ' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "Unexpected character Watch "Unexpected character New topic
Author

Unexpected character '"' (code 34) in DOCTYPE declaration

Cobain Smith
Greenhorn

Joined: Dec 20, 2010
Posts: 9
After creating the client code with the Axis2 Code Generator 1.5.4 I get the following exception at runtime. In the Web Services Explorer it works fine so the web service is ok.

What does this exception exactly tell me and how to fix it? Well I know what "unexpected charakter" means, but where does the generated code create the soap message?


log4j:WARN No appenders could be found for logger (org.apache.axis2.description.AxisService).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]: [1,63]
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:123)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.ttdev.ss.SimpleServiceStub.concat(SimpleServiceStub.java:181)
at com.ttdev.ss.Client.main(Client.java:15)
Caused by: org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]: [1,63]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:293)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:140)
at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:686)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:215)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
... 7 more
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]: [1,63]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648)
at com.ctc.wstx.sr.BasicStreamReader.startDTD(BasicStreamReader.java:2482)
at com.ctc.wstx.sr.BasicStreamReader.nextFromPrologBang(BasicStreamReader.java:2398)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2058)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:672)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 14 more
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Hi Cobain,
It seems your DTD is not declared properly on top of your xml file. Check this link for proper DOCTTYPE syntax.


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Cobain Smith
Greenhorn

Joined: Dec 20, 2010
Posts: 9
Then the code generator 1.5.4 is buggy as the generated code creates the message.
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Can you log the SOAP message just before getting this exception and validate in browser(by opening in any browser) to confirm your conclusion?
Cobain Smith
Greenhorn

Joined: Dec 20, 2010
Posts: 9
The problem was that the port wasn't defined correctly in the wsdl file. I changed it to the address http://localhost:8080/axis2/services/SimpleService as I thought that address is the endpoint. But the book I read uses http://localhost:8080/axis2/services/SimpleServiceSOAP as address. I tested both and both worked.

What's the most correct one?

 
GeeCON Prague 2014
 
subject: Unexpected character '"' (code 34) in DOCTYPE declaration