You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ole Pophal <ol...@unibw-muenchen.de> on 2005/07/14 13:14:09 UTC

SAXParseException (XML document structures must start and end within, the same entity)

Hi,

i'm working on a service, that just copies the
request message to the response message and
then adds some information to the SOAPHeader.

I'm using Java JDK 1.5.0_04, Axis 1.3 from July 13th 03:00 and
Tomcat 5.5.9.

So here is a simple TestClient and a simple EchoService, which
just copies the request message to the response message and then
adds an element to the SOAPHeader of the response message.

The TestClient:

import java.io.ByteArrayInputStream;
import java.net.URL;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.message.*;

public class TestClient {

public static void main(String[] args) {
try{
URL url = new
URL("http","localhost",8080,"/axis/services/EchoService");
Service service = new Service();
Call call=(Call) service.createCall();
call.setTargetEndpointAddress(url);
SOAPEnvelope env = new SOAPEnvelope();
env.getBody().addChildElement(new SOAPBodyElement(new
ByteArrayInputStream("<test/>".getBytes())));
SOAPEnvelope response = call.invoke(env);
System.out.println(response.getAsString());
}catch(Exception e){
e.printStackTrace();
}
}
}


The EchoService:

import org.apache.axis.*;
import org.apache.axis.message.*;

public class EchoService {

public void invoke(SOAPEnvelope req, SOAPEnvelope res){
try{
MessageContext mc = MessageContext.getCurrentContext();
mc.setResponseMessage(mc.getRequestMessage());
Message resMsg = mc.getResponseMessage();
SOAPPart resSP = (SOAPPart)resMsg.getSOAPPart();
SOAPEnvelope response = (SOAPEnvelope)resSP.getEnvelope();
SOAPHeader header =(SOAPHeader) response.getHeader();

header.addChildElement("EchoService","echo","http://somehost/echo");

}catch(Exception e){
e.printStackTrace();
}
}
}


If I run TestClient i get the following Axis Fault:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: XML document structures
must start and end within the same entity.
faultActor:
faultNode:
faultDetail:

{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException:
XML document structures must start and end within the same entity.
at [...]

I also made a System.out in the EchoService, after the additional
header-element was added and it worked. I
noticed, that the incoming SOAP-Message had the <?xml version="1.0"
encoding="UTF-8"?>-element, but
after the additional header-element was added, it's gone.


Thanks ahead for your help,
Ole Pophal