wood burning stoves 2.0*
The moose likes Web Services and the fly likes faultString: org.xml.sax.SAXParseException: Premature end of file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "faultString: org.xml.sax.SAXParseException: Premature end of file." Watch "faultString: org.xml.sax.SAXParseException: Premature end of file." New topic
Author

faultString: org.xml.sax.SAXParseException: Premature end of file.

Janga Rao
Greenhorn

Joined: Jul 17, 2011
Posts: 1
Hi,
While i was executing Web service client program in eclipse, i am getting the following exception.

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: Premature end of file.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
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)
at com.karuna.ClientProgram.main(ClientProgram.java:40)

{http://xml.apache.org/axis/}hostname:Karuna-PC

org.xml.sax.SAXParseException: Premature end of file.
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
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)
at com.karuna.ClientProgram.main(ClientProgram.java:40)
Caused by: org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
... 9 more


And my Client code is:

package com.karuna;

import java.rmi.RemoteException;

import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;


public class ClientProgram {


public static void main(String[] args) {
Service contactService = new Service();
Call callCreateUpdateCRMContact = null;

String endPoint = "http://localhost:8080/TestWeb/services/TestImpl";//args[0]; //"http://punib8450:9001/MyPOC/services/ContactWebService";
String operationName = "getUserDeatils"; //args[1]; //"returnCreateUpdateCRMContact";

try {
//construct the webservice call object
callCreateUpdateCRMContact = (Call)contactService.createCall();

//Set the endpoint
callCreateUpdateCRMContact.setTargetEndpointAddress(endPoint);

//Set the operation to be accessed
callCreateUpdateCRMContact.setOperationName(new QName(operationName));

//Register the transfer object at the client for serializer and deserializer
QName doQname = new QName("http://karuna.com","User");
callCreateUpdateCRMContact.registerTypeMapping(User.class, doQname , BeanSerializerFactory.class, BeanDeserializerFactory.class);


//Invoke the webservice
User test = (User)callCreateUpdateCRMContact.invoke(new Object[]{ 1 });


if(null != test ){
System.out.println("1:::"+ test.getId());
System.out.println("2::::"+ test.getName());
}

System.out.println("Client created successfully ");

} catch (ServiceException serviceException) {
// System.out.println("Encountered exception :"+serviceException.getMessage());
serviceException.printStackTrace();
} catch (RemoteException remoteException) {
// System.out.println("Encountered exception :"+remoteException.getMessage());
remoteException.printStackTrace();
}

}

}

And my service class is:

package com.karuna;

public class TestImpl {


public User getUserDeatils(int empNo){

System.out.println("Karuna empno ::"+ empNo);
User user = new User();
user.setId(empNo);
user.setName("Karuina");
return user;

}

}


Please provide me the solution ASAP.

Thanks in advance.
Karuna.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12760
    
    5
You really need to see what is being transmitted using something like TCPMON or SOAPui but I don't think this can be done from inside Eclipse.

Right offhand I would bet that you are not getting through to the SOAP service at all - instead you are getting some kind of HTML error response which the client can't interpret.

Bill
 
 
subject: faultString: org.xml.sax.SAXParseException: Premature end of file.
 
Similar Threads
Soap With Attachment Axis Fault
Unable to send mail via Web Service
javax.naming.NameNotFoundException: HelloBean not bound
Axis Client Classes and Web Service
Webservices AXIS fault exception while testing webservices