Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

org.xml.sax.SAXParseException: Content is not allowed in prolog.

Status
Not open for further replies.

shelly2003

Programmer
Nov 7, 2003
5
IN
am using tomcat4.0,axis and xerces-2_5_0 parser.I compiled a client code.It is compiled well.But when i run that client code then a error is coming:
INFO: Mapping Exception to AxisFault
AxisFault
faultCode: {faultString: org.xml.sax.SAXParseException: Content is not allowed in prolog.
faultActor: null
faultDetail:
stackTrace: org.xml.sax.SAXParseException: Content is not allowed in pro
log.
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(Deserializa
tionContextImpl.java:213)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:457)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:362)
at org.apache.axis.client.Call.invokeEngine(Call.java:2046)
at org.apache.axis.client.Call.invoke(Call.java:2016)
at org.apache.axis.client.Call.invoke(Call.java:1786)
at org.apache.axis.client.Call.invoke(Call.java:1711)
at org.apache.axis.client.Call.invoke(Call.java:1251)
at HelloWorldClient.main(HelloWorldClient.java:33)


org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.axis.AxisFault.makeFault(AxisFault.java:117)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:462)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:362)
at org.apache.axis.client.Call.invokeEngine(Call.java:2046)
at org.apache.axis.client.Call.invoke(Call.java:2016)
at org.apache.axis.client.Call.invoke(Call.java:1786)
at org.apache.axis.client.Call.invoke(Call.java:1711)
at org.apache.axis.client.Call.invoke(Call.java:1251)
at HelloWorldClient.main(HelloWorldClient.java:33)
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(Deserializa
tionContextImpl.java:213)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:457)
... 7 more
Caught an exception: org.xml.sax.SAXParseException: Content is not allowed in pr
olog.

How can i correct this error
 
I just love these crystal ball questions! :)

The prolog is everything that comes before the root element of your XML document. This can include the XML declaration, comments, internal DTD, and maybe other stuff, but not document content.

You might have more than one root element (a no-no) or stray text or Zeus knows what. We're never going to be able to figure it out for you if you don't show us the code.
 
hi harebrain,
Thanks for your reply.I will be gratefull to you if you will be able to solve my problem.Here is the code:

for client:

// The Axis package is used to generate and handle the SOAP call
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;

// The rpc package is used to create the RPC call
import javax.xml.namespace.QName;
import javax.xml.rpc.NamespaceConstants;

// The java.net package gives us a URL class
import java.net.URL;

public class HelloWorldClient {
/**
* Test main.
*/
public static void main(String args[]) {
System.out.println("HelloWorld.main: Entering...");

try {
String url = " String sender = "Reader";
Service service = new Service();
Call call = (Call) service.createCall();

call.setTargetEndpointAddress(new URL(url));
call.setSOAPActionURI("sayHello");
call.setEncodingStyle(NamespaceConstants.NSURI_SOAP_ENCODING);
call.setOperationName(new QName("urn:helloworld", "sayHello"));
//call.setReturnType(XMLType.XSD_STRING);

String hello = (String)call.invoke(new Object[] { sender } );

System.out.println("The Web Service returned: " + hello);
System.out.println ("HelloWorld.main: All done!");

} catch (Exception exception) {
System.err.println("Caught an exception: " + exception);
}
}
}


For web service:

public class HelloWorld {
/**
* Returns &quot;Hello <sender>!&quot;.
*/
public String sayHello(String sender) {
return &quot;Hello &quot; + sender + &quot;!&quot;;
}
}
 
Me and my big mouth! I'm afraid I can't help you with this code, but now maybe somebody else can.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top