Hi,
I have written an handler which implements the handleRequest et
handleFault methods with Axis 1.2.1 and Jonas 4.6.6
In the handleRequest method, if I have a bad parameter in the request I
have to throw a SOAPFaultException
in the handleRequest method:
Detail detail = null;
detail = SOAPFactory.newInstance().createDetail();
detail.addChildElement( "Stock Trade" ).addTextNode( "failed" );
throw new SOAPFaultException(new QName(
"http://www.francetelecom.com/2006/int", "ServiceFailed" ),
"action parameter
is null",
"http://www.francetelecom.com/2006/int/handler",
detail);
And according to the specifications, the handleFault method is called:
But in this method I don't want to send a SOAPFault but a SOAP Message
with a custom element (Response) in the soap message;
In the handleFault method:
SOAPMessageContext messagectx = (SOAPMessageContext) context;
SOAPFactory factory = SOAPFactory.newInstance();
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage msg = mf.createMessage();
msg.getSOAPHeader().detachNode();
SOAPBody body = msg.getSOAPBody();
Name testName = factory.createName("TestResponse", "test",
"http://www.francetelecom.com/2006/int");
SOAPBodyElement theBodyElement = body.addBodyElement(testName);
Name responseName = factory.createName("Reponse");
theBodyElement.addChildElement(responseName);
messagectx.setMessage(msg);
//For debugging
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
messagectx.getMessage().writeTo(outputStream);
logger.debug(outputStream.toString());
BUT:
the client receives a RemoteException and not the custom soap message
with the TestResponse element that I have built in the handleFault method.
In the console, the soap message contains the custom element.
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<test:TestResponse xmlns:test="http://www.francetelecom.com/2006/int">
<Reponse xmlns=""/>
</test:TestResponse>
</soapenv:Body>
</soapenv:Envelope>
2006-06-29 14:47:42,905 : JonasHandler.onFault : *------* Fault
1/ How can I solve this problem ?
2/ Where the SOAPFaultException exception has gone when I throw it ?
Thanks for your help.
Olivier
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]