Hi there everyone,

My apologies beforehand for the large amount of code etc. I am new to Axis2 and I am currently implementing a web service. All is going well except when executing the code below I get the following error:

INFO - [org.apache.commons.httpclient.HttpMethodDirector] - I/O exception (org.apache.axis2.AxisFault) caught when processing request: Can not output XML declaration, after other output has already been done.; nested exception is: javax.xml.stream.XMLStreamException: Can not output XML declaration, after other output has already been done. INFO - [org.apache.commons.httpclient.HttpMethodDirector] - Retrying request INFO - [org.apache.commons.httpclient.HttpMethodDirector] - I/O exception (org.apache.axis2.AxisFault) caught when processing request: Can not output XML declaration, after other output has already been done.; nested exception is: javax.xml.stream.XMLStreamException: Can not output XML declaration, after other output has already been done. INFO - [org.apache.commons.httpclient.HttpMethodDirector] - Retrying request INFO - [org.apache.commons.httpclient.HttpMethodDirector] - I/O exception (org.apache.axis2.AxisFault) caught when processing request: Can not output XML declaration, after other output has already been done.; nested exception is: javax.xml.stream.XMLStreamException: Can not output XML declaration, after other output has already been done. INFO - [org.apache.commons.httpclient.HttpMethodDirector] - Retrying request ERROR - [soap-service] - AxisFault Cause: org.apache.axis2.AxisFault: Can not output XML declaration, after other output has already been done.; nested exception is: javax.xml.stream.XMLStreamException: Can not output XML declaration, after other output has already been done.; nested exception is: org.apache.axis2.AxisFault: Can not output XML declaration, after other output has already been done.; nested exception is: javax.xml.stream.XMLStreamException: Can not output XML declaration, after other output has already been done.

Can anyone please have a look and let me know where I am going wrong. Thanks a million!

//Build the SOAP message SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
           log.debug("Creating SOAPEnvelope...\n");
           SOAPEnvelope envelope = factory.createSOAPEnvelope();
           log.debug("Creating SOAPHeader...\n");
           SOAPHeader header = factory.createSOAPHeader(envelope);
ns = factory.createOMNamespace(namespace, "");
           log.debug("Adding elements to SOAPHeader...\n");
OMElement authorization = factory.createOMElement("AuthHeader", ns);
           OMElement username = factory.createOMElement("Username", null);
           username.setText("cxchange");
           OMElement password = factory.createOMElement("Password", null);
           password.setText("test");
authorization.addChild(username);
           authorization.addChild(password);
header.addChild(authorization); log.debug("Creating SOAPBody...\n");
           SOAPBody body = factory.createSOAPBody(envelope);
           OMElement send = factory.createOMElement("Send", ns);
OMElement dataIdentifier = factory.createOMElement("dataIdentifier", null);
           dataIdentifier.setText("orderrequest");
           OMElement xmlData = factory.createOMElement("xmlData", null);
           xmlData.setText(fileData);
send.addChild(dataIdentifier); send.addChild(xmlData); body.addChild(send); EndpointReference targetEPR = new EndpointReference(url);
           // Make the request message
           log.debug("Setting up options for ServiceClient...\n");
           Options options = new Options();
           options.setTo(targetEPR);
           log.debug("Target endpoint at 16:55 is: " + targetEPR + "\n");

           ServiceClient sender = new ServiceClient();
           sender.setOptions(options);
           log.debug("Options set for ServiceClient...\n");

           log.debug("Sending envelope...\n");
           log.debug("Envelope data: \n");
           log.debug(envelope);
           OMElement result = sender.sendReceive(envelope);

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to