> Empty response send by SOAPEventhandler when Exception occurs
> -------------------------------------------------------------
>
> Key: OFBIZ-745
> URL:
https://issues.apache.org/jira/browse/OFBIZ-745> Project: OFBiz
> Issue Type: Bug
> Components: framework
> Affects Versions: SVN trunk
> Environment: SUSE Linux 10.1 & MySQL 5.0.18
> Reporter: Michael Imhof
> Assignee: Jacques Le Roux
> Fix For: SVN trunk
>
> Attachments: patch745.txt
>
>
> Calling a OfBiz SOAP Service with wrong arguments returns an "empty response"
> instead of a Fault SOAP envelope.
> Class:
> =====
> SOAPEventhandler.java
> Solution
> =======
> New sendError(..) methods:
> private void sendError(HttpServletResponse res, String errorMsg) {
> sendError(res, new AxisFault(errorMsg));
> }
>
> private void sendError(HttpServletResponse res, Exception e) {
> AxisFault axisFault = null;
> if (e instanceof AxisFault) {
> axisFault = (AxisFault)e;
> } else {
> axisFault = AxisFault.makeFault(e);
> }
>
> SOAPEnvelope env = new SOAPEnvelope();
> try {
> SOAPBody body = env.getBody();
> SOAPFault fault = body.addFault();
> fault.setFaultString(axisFault.getFaultString());
> fault.setFaultCode(axisFault.getFaultCode().getLocalPart());
> fault.setFaultActor(axisFault.getFaultActor());
> env.setEncodingStyle(Constants.URI_LITERAL_ENC);
> Message msg = new Message(env);
>
> msg.writeTo(res.getOutputStream());
> res.flushBuffer();
> } catch(SOAPException se) {
> Debug.logWarning(se, "SOAP response not generated", module);
> } catch(IOException ie) {
> Debug.logWarning(ie, "SOAP response not generated", module);
> }
> }