private void serializeRuntimeException() throws WebServiceException { try { MessageFactory factory = _soapContext.getMessageFactory(); SOAPMessage message = factory.createMessage(); QName faultcode = new QName( message.getSOAPBody().getNamespaceURI(), "Server", message.getSOAPBody().getPrefix()); message.getSOAPBody().addFault(faultcode, _runtimeException.getMessage()); _soapContext.setMessage(message); _source = _soapContext.getMessage().getSOAPPart().getContent(); } catch (SOAPException se) { throw new WebServiceException(se); } }
private boolean handleFault(int i) { Handler handler = _chain.get(i); boolean success = false; _invoked[i] = true; try { if (handler instanceof LogicalHandler) { _logicalContext.getMessage().setPayload(_source); success = handler.handleFault(_logicalContext); _source = _logicalContext.getMessage().getPayload(); } else if (handler instanceof SOAPHandler) { try { _soapContext.setMessage(_source); success = handler.handleFault(_soapContext); _source = _soapContext.getMessage().getSOAPPart().getContent(); } catch (SOAPException e) { throw new WebServiceException(e); } } else { throw new WebServiceException( L.l("Unsupported Handler type: {0}", handler.getClass().getName())); } _protocolException = null; } catch (ProtocolException e) { _protocolException = e; serializeProtocolException(); } catch (RuntimeException e) { _runtimeException = e; serializeRuntimeException(); } return success; }
private void serializeProtocolException() throws WebServiceException { if (_protocolException instanceof SOAPFaultException) { SOAPFaultException sfe = (SOAPFaultException) _protocolException; SOAPFault fault = sfe.getFault(); try { MessageFactory factory = _soapContext.getMessageFactory(); SOAPMessage message = factory.createMessage(); message.getSOAPBody().addChildElement(fault); _soapContext.setMessage(message); _source = _soapContext.getMessage().getSOAPPart().getContent(); } catch (SOAPException se) { throw new WebServiceException(se); } } else { throw new WebServiceException(L.l("Unsupported ProtocolException: {0}", _protocolException)); } }
private void close(int i) { Handler handler = _chain.get(i); if (!_invoked[i]) return; _invoked[i] = false; if (handler instanceof LogicalHandler) { _logicalContext.getMessage().setPayload(_source); handler.close(_logicalContext); _source = _logicalContext.getMessage().getPayload(); } else if (handler instanceof SOAPHandler) { try { _soapContext.setMessage(_source); handler.close(_soapContext); _source = _soapContext.getMessage().getSOAPPart().getContent(); } catch (SOAPException e) { throw new WebServiceException(e); } } }