SOAPMessage error using AXIS
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jennifer_Werner
Posted On:   Tuesday, November 22, 2005 02:32 PM

Hi I am using AXIS to create a simple SOAPMessage and send it using the SOAPConnectionFactory, however I keep getting a SAX Parser exception and I can't figure out why. Here is the code public void testEnvelope() throws Exception { String xmlString = " <?xml version="1.0" encoding="UTF-8"?> " + " " + " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" " + " xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" " + " xmlns:xsd="http://www.w3.org/2001/XMLSchema">    More>>

Hi I am using AXIS to create a simple SOAPMessage and send it using the SOAPConnectionFactory, however I keep getting a SAX Parser exception and I can't figure out why. Here is the code

public void testEnvelope() throws Exception {

String xmlString =
" <?xml version="1.0" encoding="UTF-8"?>
" +

"
" +

" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
" +

" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
" +

" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
" +

"
" +

"
" +

"
" +

"
" +

" wsAuthUID
" +

" wsAuthPwd
" +

"
" +

" jsmith@bellmobility.ca
" +

"
" +

"
" +

"
" +

" ";

MessageFactory mf = MessageFactory.newInstance();

SOAPMessage smsg =
mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));

SOAPPart sp = smsg.getSOAPPart();

SOAPEnvelope se = (SOAPEnvelope)sp.getEnvelope();

smsg.writeTo( System.out );

SOAPConnection conn = SOAPConnectionFactory.newInstance().createConnection();

SOAPMessage reply = conn.call(smsg, url);

System.out.println( "
---- Reply Message ----
" );

reply.writeTo( System.out );
}

which nets me the following error:

javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
at org.apache.axis.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:95)
at SOAP.SOAPConnectionTest.testEnvelope(SOAPConnectionTest.java:90)
at SOAP.SOAP.btnConvert2Xml_actionPerformed(SOAP.java:146)
at SOAP.Compare_btnCompare_actionAdapter.actionPerformed(SOAP.java:654)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
Caused by: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
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:424)
at org.apache.axis.client.Call.invokeEngine(Call.java:2785)
at org.apache.axis.client.Call.invoke(Call.java:2748)
at org.apache.axis.client.Call.invoke(Call.java:1862)
at org.apache.axis.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:90)
... 26 more
Caused by: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1171)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
... 31 more

XMLSpy tells me the document is well formed. Can anyone help me please???

   <<Less
About | Sitemap | Contact