El jue, 14-12-2006 a las 23:09 +0200, Schalk Neethling escribió: > 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.
I've seen this just yesterday myself.
> SOAPBody body = factory.createSOAPBody(envelope);
> OMElement send = factory.createOMElement("Send", ns);
[ Lots of code removed. ]
> body.addChild(send);
> ServiceClient sender = new ServiceClient();
> sender.setOptions(options);
> OMElement result = sender.sendReceive(envelope);
The solution is to pass sendReceive the send element directly; don't
pass it the envelope and body elements. SendReceive ends up
unconditionally wrapping the supplied OMElement within a body element.
Note that you can still set headers this way, by means of the
ServiceClient instance.
In my case, I needed to add two elements to the body, so I had to create
the whole envelope and use the OperationClient interface instead to run
the operation. I can give you skeleton code to do that, in case you need
it, it's only slightly more complex than the above.
Greetings,
--
Javier Kohen <[EMAIL PROTECTED]>
ICQ: blashyrkh #2361802
Jabber: [EMAIL PROTECTED]
signature.asc
Description: Esta parte del mensaje está firmada digitalmente
