Two Laptop Bag*
The moose likes Web Services and the fly likes Getting Exception | Premature End of file | Parsing string xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Getting Exception | Premature End of file | Parsing string xml" Watch "Getting Exception | Premature End of file | Parsing string xml" New topic
Author

Getting Exception | Premature End of file | Parsing string xml

Gurvinder Singh
Greenhorn

Joined: Nov 10, 2008
Posts: 27
Hi

I am trying to test a webservice locally on my system which takes a string xml input parameter as request.
For this i am converting my xml to string via string builder and passing it as a request to the webservice.
Now, the webservice call is happening fine and i can get to the backend server code.

But when i try to unmarshal the string xml through JAXB, i get the following error

18:15:43,995 ERROR [InventoryUpdateService]
javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: Premature end of file.]
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:514)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:215)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:184)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:184)
at com.scvl.oms.inventory.InventoryUpdateService.getJAXBObject(InventoryUpdateService.java:248)
at com.scvl.oms.inventory.InventoryUpdateService.inventoryService(InventoryUpdateService.java:105)
at webservices.InventoryServiceSEIImpl.inventoryService(InventoryServiceSEIImpl.java:53)
at webservices.InventoryServiceSEI_Tie.invoke_inventoryService(InventoryServiceSEI_Tie.java:54)
at webservices.InventoryServiceSEI_Tie.processingHook(InventoryServiceSEI_Tie.java:132)
at com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:364)
at com.sun.xml.rpc.server.http.ea.JAXRPCServletDelegate.doPost(JAXRPCServletDelegate.java:243)
at com.sun.xml.rpc.server.http.JAXRPCServlet.doPost(JAXRPCServlet.java:133)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at atg.webservice.filter.SOAPFactoriesFilter.doFilter(SOAPFactoriesFilter.java:153)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at atg.webservice.WSDLImportFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1059)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)
... 36 more


I have checked the xml and it is a well formed xml. I am not able to understand where the problem is.
My XML is as follows::

<?xml version="1.0" encoding="UTF-8"?>
<Inventory xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
payloadID="20110109.1.9832446010@test.com" timestamp="2011-02-11T23:00:06-08:00">
<Header>
<From>
<Credential domain="ATG">
<Identity>IMS</Identity>
</Credential>
</From>
<To>
<Credential domain="ATG">
<Identity>Website</Identity>
</Credential>
</To>
</Header>
<Request>
<InventoryRecords>
<InventoryRecord>
<InternalPartID displayName="Gold Bracelet">sku123</InternalPartID>
<StockLevel>10</StockLevel>
<AvailabilityStatus>1004</AvailabilityStatus>
<AvailabilityDate/>
<StockThreshold>10</StockThreshold>
<BackOrderLevel/>
<BackOrderThreshold/>
<PreOrderLevel/>
<PreOrderThreshold/>
</InventoryRecord>
<InventoryRecord>
<InternalPartID displayName="Nice Shoe">sku234</InternalPartID>
<StockLevel>23</StockLevel>
<AvailabilityStatus>1004</AvailabilityStatus>
<AvailabilityDate/>
<StockThreshold>10</StockThreshold>
<BackOrderLevel/>
<BackOrderThreshold/>
<PreOrderLevel/>
<PreOrderThreshold/>
</InventoryRecord>
</InventoryRecords>
</Request>
</Inventory>



Please provide with some pointers.

Thanks
Gurvinder
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Exception | Premature End of file | Parsing string xml
 
Similar Threads
problem to send file
JaxB unexpected element (uri:"", local:"Installer")
JAXB Validation Issue - [org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of el
Attribute "value" must be declared for element type "property"???
Newbie HelloWorld Struts.xml problem