• Post Reply Bookmark Topic Watch Topic
  • New Topic

org.xml.sax.SAXParseException: The root element is required in a well-formed document.

 
Ganesh kumawat
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am getting the following Exception when i am trying to access a web service.....
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString: org.xml.sax.SAXParseException: The root element is required in a well-formed document. Message being parsed:
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString: org.xml.sax.SAXParseException: The root element is required in a well-formed document. Message being parsed:
faultActor:
faultNode:
faultDetail:

org.xml.sax.SAXParseException: The root element is required in a well-formed document. Message being parsed:
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1675)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:675)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:128)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)
at org.apache.axis.client.Call.invokeEngine(Call.java:2564)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at com.uniteller.partnerintegration.earthport.MerchantAPISoapBindingStub.submitDocument(MerchantAPISoapBindingStub.java:166)
at com.uniteller.partnerintegration.earthport.EPTestDriver.main(EPTestDriver.java:292)


org.xml.sax.SAXParseException: The root element is required in a well-formed document. Message being parsed:
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1675)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:675)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:128)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)
at org.apache.axis.client.Call.invokeEngine(Call.java:2564)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at com.uniteller.partnerintegration.earthport.MerchantAPISoapBindingStub.submitDocument(MerchantAPISoapBindingStub.java:166)
at com.uniteller.partnerintegration.earthport.EPTestDriver.main(EPTestDriver.java:292)



I am sending the request using Java as:
<soapenv:Envelope xmlns:v1="http://customer.endpoint.earthport.com/api/merchant" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-87" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>abc</wsse:Username>
<wsse:Password type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xyzpass</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">EOR6xNbxUNzgyHQrASfGXA==</wsse:Nonce>
<wsu:Created>2014-04-09T12:14:14.775Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<submitDocument>
<parameters>
<echo version="1.0" xmlns="http://customer.endpoint.earthport.com/api/merchant/echo">
<echoRequest>Hello!</echoRequest>
</echo>
</parameters>
</submitDocument>
</soapenv:Body>
</soapenv:Envelope>

However, when i send the same request using SOAP UI tool,,I am getting Response with SUCCESS.


 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However, when i send the same request using SOAP UI tool,,I am getting Response with SUCCESS.


Obviously we must suspect the Java code you have written to send a request. Where is is?

When your code tries to send a request, where does the request text come from?

Bill
 
Paul Clapham
Sheriff
Posts: 21885
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll notice that the error message says "Message being parsed:" and after that there is not bad XML, there is just nothing. So as Bill said, you should suspect that your code is sending the wrong text; in particular you should suspect that it isn't sending any text at all for the XML.
 
Ganesh kumawat
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Java code is{Element "_main" is the main xml shown above.}:
MerchantAPIService _locator = new MerchantAPIServiceLocator();

try
{
System.out.println("gettin port...");
Request d = new Request();
_submitDocument vb = new _submitDocument();


SOAPEnvelope se = new SOAPEnvelope();


Name _name = se.createName("name");
Name _user = se.createName("Username");
Name _pass = se.createName("Password");
Name _type = se.createName("type");
Name _min = se.createName("minOccurs");
Name _max = se.createName("maxOccurs");
Name _target = se.createName("targetNamespace");
Name _xml = se.createName("xmlns");
Name _xmlV1 = se.createName("xmlns:v1");
Name _xsd = se.createName("xmlns:xsd");
Name _xmlsoap = se.createName("xmlns:soapenv");
Name _elem = se.createName("elementFormDefault");
Name _use = se.createName("use");
Name _base = se.createName("base");
Name _value = se.createName("value");
Name _ver = se.createName("version");
Name _wsu = se.createName("xmlns:wsu");
Name _msg = se.createName("MessageSize");
Name _encoding = se.createName("EncodingType");
Name _endpoint = se.createName("Endpoint");
Name _interface = se.createName("Interface");
Name _operation = se.createName("Operation");
Name _follow = se.createName("FollowRedirects");
Name _wss = se.createName("WSS-PasswordType");
Name _pretty = se.createName("PrettyPrint");
Name _wsuxml = se.createName("http://schemas.xmlsoap.org/ws/2003/06/utility");
Name _soap = se.createName("SOAP-ENV:mustUnderstand");
Name _wsuId = se.createName("wsu:Id");
Name _wse = se.createName("xmlns:wsse");
Name _soapXml = se.createName("xmlns:SOAP-ENV");
Name _ns1 = se.createName("xmlns:ns1");
Name _ns2 = se.createName("xmlns:ns2");
Name _xmlSoapc = se.createName("xmlns:SOAP-ENC");
Name _soapEnv = se.createName("SOAP-ENV:encodingStyle");
Name _xsi = se.createName("xmlns:xsi");

MessageElement _schema = new MessageElement();
MessageElement _main = new MessageElement();
MessageElement _data = new MessageElement();
MessageElement _data1 = new MessageElement();
MessageElement _data2 = new MessageElement();

MessageElement _schema1 = new MessageElement();
MessageElement _schema2 = new MessageElement();
MessageElement _schema3 = new MessageElement();
MessageElement _schema4 = new MessageElement();
MessageElement _schema5 = new MessageElement();

MessageElement _inner = new MessageElement();
MessageElement _inner1 = new MessageElement();
MessageElement _inner2 = new MessageElement();

MessageElement _inSequence = new MessageElement();
MessageElement _inSequence1 = new MessageElement();

MessageElement _security = new MessageElement();
MessageElement _uToken = new MessageElement();
MessageElement _uName = new MessageElement();
MessageElement _uPass = new MessageElement();
MessageElement _time = new MessageElement();

MessageElement _restriction = new MessageElement();
MessageElement _inRestriction = new MessageElement();
MessageElement _inRestriction1 = new MessageElement();
MessageElement _nonce = new MessageElement();

_nonce.setName("wsse:Nonce");
_nonce.addAttribute(_encoding,"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
_nonce.addTextNode("EOR6xNbxUNzgyHQrASfGXA==");

_time.setName("wsu:Created");
_time.addTextNode("2014-04-09T12:14:14.775Z");

_uName.setName("ns2:Username");
_uName.addTextNode("abc");

_uPass.setName("ns2:Password");
_uPass.addTextNode("xyzPwd");


_uToken.setName("ns2:UsernameToken");
_uToken.addAttribute(_wsuId,"UsernameToken-87");
_uToken.addAttribute(_wsu,"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
_uToken.addChild(_uName);
_uToken.addChild(_uPass);


_security.setName("ns2:Security");
_security.addAttribute(_soap,"1");
_security.addChild(_uToken);

_inRestriction.setName("minLength");
_inRestriction.addAttribute(_value,"0");
_inRestriction.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

_inRestriction1.setName("maxLength");
_inRestriction1.addAttribute(_value,"255");
_inRestriction1.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

//_inSequence.setPrefix("xsd");
_inSequence.setName("element");
_inSequence.addAttribute(_name,"echoRequest");
_inSequence.addAttribute(_type,"EchoStringType");
_inSequence.addAttribute(_min,"1");
_inSequence.addAttribute(_max,"1");
_inSequence.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

//_inSequence1.setPrefix("xsd");
_inSequence1.setName("element");
_inSequence1.addAttribute(_name,"echoResponse");
_inSequence1.addAttribute(_type,"EchoStringType");
_inSequence1.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

//_inner1.setPrefix("xsd");
_inner1.setName("attribute");
_inner1.addAttribute(_name,"version");
_inner1.addAttribute(_type,"xsd:decimal");
_inner1.addAttribute(_use,"required");
_inner1.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

//_inner2.setPrefix("xsd");
_inner2.setName("sequence");
_inner2.addChild(_inSequence1);
_inner2.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

//_restriction.setPrefix("xsd");
_restriction.setName("restriction");
_restriction.addAttribute(_base,"xsd:string");
_restriction.addChild(_inRestriction);
_restriction.addChild(_inRestriction1);
_restriction.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

//_inner.setPrefix("xsd");
_inner.setName("sequence");
_inner.addChild(_inSequence);
_inner.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

_schema1.setName("element");
//_schema1.setPrefix("xsd");
_schema1.addAttribute(_name,"echo");
_schema1.addAttribute(_type,"EchoType");
_schema1.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

_schema2.setName("element");
//_schema2.setPrefix("xsd");
_schema2.addAttribute(_name,"echoResponse");
_schema2.addAttribute(_type,"EchoResponseType");
_schema2.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

_schema3.setName("complexType");
//_schema3.setPrefix("xsd");
_schema3.addAttribute(_name,"EchoType");
_schema3.addChild(_inner);
_schema3.addChild(_inner1);
_schema3.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

_schema4.setName("complexType");
//_schema4.setPrefix("xsd");
_schema4.addAttribute(_name,"EchoResponseType");
_schema4.addChild(_inner2);
_schema4.setNamespaceURI("http://www.w3.org/2001/XMLSchema");

_schema5.setName("simpleType");
//_schema5.setPrefix("xsd");
_schema5.addAttribute(_name,"EchoStringType");
_schema5.addChild(_restriction);
_schema5.setNamespaceURI("http://www.w3.org/2001/XMLSchema");


_schema.setName("schema");
//_schema.setPrefix("soapenv");
_schema.setNamespaceURI("http://www.w3.org/2001/XMLSchema");
_schema.addAttribute(_xml,"http://customer.endpoint.earthport.com/api/merchant/v1/services/echo");
_schema.addAttribute(_target,"http://customer.endpoint.earthport.com/api/merchant/v1/services/echo");
_schema.addAttribute(_elem,"qualified");
_schema.addChild(_schema1);
_schema.addChild(_schema2);
_schema.addChild(_schema3);
_schema.addChild(_schema4);
_schema.addChild(_schema5);

MessageElement _header = new MessageElement();
MessageElement _body = new MessageElement();
MessageElement _submit = new MessageElement();
MessageElement _param = new MessageElement();


_data1.setName("echoRequest");
_data1.addTextNode("test");

_data.setName("echo");
_data.addAttribute(_xsi,"http://www.w3.org/2001/XMLSchema-instance");
_data.addAttribute(_xsd,"http://www.w3.org/2001/XMLSchema");
_data.addAttribute(_ver,"1.0");
_data.addAttribute(_xml,"http://customer.endpoint.earthport.com/api/merchant/v1/services/echo");
_data.addChild(_data1);

_param.setName("parameters");
_param.addAttribute(_xml," ");
_param.addChild(_data);

_submit.setName("ns1:submitDocument");
_submit.addChild(_param);


_header.setName("SOAP-ENV:Header");
_header.addChild(_security);


_body.setName("SOAP-ENV:Body");
_body.addChild(_submit);
//_body.setNamespaceURI("http://schemas.xmlsoap.org/soap/envelope/");

//_main.setPrefix("SOAP-ENV");
_main.setName("SOAP-ENV:Envelope");
//_main.setNamespaceURI("http://schemas.xmlsoap.org/soap/envelope/");
_main.addAttribute(_soapXml,"http://schemas.xmlsoap.org/soap/envelope/");
_main.addAttribute(_ns1,"http://customer.endpoint.earthport.com/");
_main.addAttribute(_ns2,"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
_main.addAttribute(_xsd,"http://www.w3.org/2001/XMLSchema" );
_main.addAttribute(_xmlSoapc,"http://schemas.xmlsoap.org/soap/encoding/");
_main.addAttribute(_soapEnv,"http://schemas.xmlsoap.org/soap/encoding/");
_main.addChild(_header);
_main.addChild(_body);


System.out.println(_schema.getAsDOM().toString());
System.out.println(_main.toString());


MessageElement _elm[] = new MessageElement[]{_schema,_main};


d.set_any(_elm);

vb.setParameters(d);

MerchantAPI _port = _locator.getMerchantAPI();

_submitDocumentResponse vg = _port.submitDocument(vb);

System.out.println(vg.getSubmitDocumentReturn());

Response ff=vg.getSubmitDocumentReturn();

System.out.println(ff.get_any().length);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!