You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by xu cai <je...@gmail.com> on 2006/07/23 12:10:39 UTC

Re: Got well-formd soap response, but still with org.xml.sax.SAXParseException: Premature end of file

Really weird, I change a little on
org.apache.axis.encoding.DeserializationContext.java,
write the Soap response to a txt file, and parse the the Soap response from
the txt file.
and this time, the boring "org.xml.sax.SAXParseException: Premature end of
file" disappeared.

Following is snippet of org.apache.axis.encoding.DeserializationContext.java,
I made change from line 237 to 239.

   231      public void parse() throws SAXException
   232      {
   233          if (inputSource != null) {
   234              SAXParser parser = XMLUtils.getSAXParser();
   235              try {
   236                  parser.setProperty("
http://xml.org/sax/properties/lexical-handler", this);
   237                  printIs(inputSource);  //write the soap response to
/tmp/a.txt
   238                  parser.parse(new
FileInputStream("/tmp/a.txt"),this);  // parse the /tmp/a.txt
   239                  //parser.parse(inputSource, this);
   240
   241                  try {
   242                      // cleanup - so that the parser can be reused.
   243                      parser.setProperty("
http://xml.org/sax/properties/lexical-handler", null
LexicalHandler);
   244                  } catch (Exception e){
   245                      // Ignore.
   246                  }
   247
   248                  // only release the parser for reuse if there wasn't
an
   249                  // error.  While parsers should be reusable, don't
trust
   250                  // parsers that died to clean up appropriately.
   251                  XMLUtils.releaseSAXParser(parser);
   252              } catch (IOException e) {
   253                  throw new SAXException(e);
   254              }
   255              inputSource = null;
   256          }
   257      }
   258


So seems that the reply soap message is well-formed, but may be less of one
of control character ?   Could anybody give me a explain ? or it's a bug of
Axis 1.4?





On 7/23/06, xu cai <je...@gmail.com> wrote:
>
>  hi, this time, I debug with tcpmon, and find that the soap response is
> well-formed.
> but I still get a "org.xml.sax.SAXParseException: Premature end of file".
>
> I find that there is an namespace definition "xmlns:ns1=
> http://www.test.com/test/i01 in soap response, and xml parser may not get
> schema of this namespace and finally report the error.
>
> So my question is how to associate my xsd file with the namespace in
> client side code ? so that the the following generated soap response can be
> parsed well ?
>
> thanks
> -Jeffrey
>
> soap response:
>
> <?xml version="1.0" encoding="utf-8"?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema " xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"><http://www.w3.org/2001/XMLSchema-instance%22%3E>
> <soapenv:Body>
> <ns1:requestResponse soapenv:encodingStyle="
> http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.test.com/test/i01"><http://www.test.com/test/i01%22%3E>
> <requestReturn href="#id0"/>
> </ns1:requestResponse>
> <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="
> http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Reply"
> xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="
> http://www.test.com/test/i01"> <http://www.test.com/test/i01%22%3E>
> <Status xsi:type="xsd:boolean">true</Status>
> <Reason xsi:type="soapenc:string">hello world</Reason>
> <Size xsi:type="xsd:int">0</Size>
> <AbsoluteSize xsi:type="xsd:int">0</AbsoluteSize>
> <StartRow xsi:type="xsd:int">0</StartRow>
> </multiRef>
> </soapenv:Body>
> </soapenv:Envelope>
>
> exception:
> AxisFault
>  faultCode: {
> http://schemas.xmlsoap.org/soap/envelope/}Server.userException<http://schemas.xmlsoap.org/soap/envelope/%7DServer.userException>
>  faultSubcode:
>  faultString: org.xml.sax.SAXParseException : Premature end of file.
>  faultActor:
>  faultNode:
>  faultDetail:
>         {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException
> <http://xml.apache.org/axis/%7DstackTrace:org.xml.sax.SAXParseException>:
> Premature end of file.
>         at
> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
> Source)
>         at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown
> Source)
>         at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> Source)
>         at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> Source)
>         at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
>         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
> Source)
>         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
> Source)
>         at org.apache.xerces.parsers.XMLParser.parse (Unknown Source)
>         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
> Source)
>         at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
> Source)
>         at javax.xml.parsers.SAXParser.parse (SAXParser.java:375)
>         at org.apache.axis.encoding.DeserializationContext.parse(
> DeserializationContext.java:235)
>         at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:697)
>         at org.apache.axis.Message.getSOAPEnvelope (Message.java:435)
>         at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(
> MustUnderstandChecker.java:62)
>         at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
>         at org.apache.axis.client.Call.invokeEngine (Call.java:2784)
>         at org.apache.axis.client.Call.invoke(Call.java:2767)
>         at org.apache.axis.client.Call.invoke(Call.java:2443)
>         at org.apache.axis.client.Call.invoke(Call.java:2366)
>         at org.apache.axis.client.Call.invoke(Call.java:1812)
>
>
>



-- 
- xucai