private QName getPayloadElementName(SOAPMessage soapMessage) { try { // we only care about the first element node, not text nodes Element element = DOMUtils.getFirstElement(SAAJUtils.getBody(soapMessage)); if (element != null) { return DOMUtils.getElementQName(element); } } catch (Exception e) { //ignore } return null; }
public MessageFactory getMessageFactory() { if (this.soapBinding instanceof SoapBindingInfo) { SoapBindingInfo bindingInfo = (SoapBindingInfo) this.soapBinding; try { return SAAJFactoryResolver.createMessageFactory(bindingInfo.getSoapVersion()); } catch (SOAPException e) { throw new WebServiceException(BUNDLE.getString("SAAJ_FACTORY_ERR"), e); } } return null; }
public SOAPFactory getSOAPFactory() { if (this.soapBinding instanceof SoapBindingInfo) { SoapBindingInfo bindingInfo = (SoapBindingInfo) this.soapBinding; try { return SAAJFactoryResolver.createSOAPFactory(bindingInfo.getSoapVersion()); } catch (SOAPException e) { throw new WebServiceException(BUNDLE.getString("SAAJ_FACTORY_ERR"), e); } } return null; }
"SOAP/HTTP"); } else if (m == Service.Mode.MESSAGE) { SAAJOutInterceptor saajOut = new SAAJOutInterceptor(); client.getOutInterceptors().add(saajOut); client.getOutInterceptors(). client.getEndpoint() .getBinding().getBindingInfo().getName())); client.getInInterceptors().add(new SAAJInInterceptor()); client.getInInterceptors() .add(new MessageModeInInterceptor(clazz,
SAAJ_OUT.handleMessage(message); SAAJInInterceptor.replaceHeaders(msg, message); } catch (SOAPException e) { e.printStackTrace();
MessageFactory factory = saajOut.getFactory(message); soapMessage = factory.createMessage(); SOAPPart part = soapMessage.getSOAPPart(); if (o instanceof Source) { StaxUtils.copy((Source)o, new SAAJStreamWriter(part)); DocumentFragment frag = soapMessage.getSOAPPart().createDocumentFragment(); try { Node body = SAAJUtils.getBody(soapMessage); Node nd = body.getFirstChild(); while (nd != null) { nd = DOMUtils.getDomElement(nd); frag.appendChild(nd); nd = SAAJUtils.getBody(soapMessage).getFirstChild(); message.put(SAAJOutInterceptor.ORIGINAL_XML_WRITER, origWriter); W3CDOMStreamWriter writer = new SAAJStreamWriter(soapMessage.getSOAPPart());
version = ((SoapMessage)msg).getVersion(); soapMessage = SAAJFactoryResolver.createMessageFactory(version).createMessage(); msg.setContent(SOAPMessage.class, soapMessage); SOAPBody body = SAAJUtils.getBody(soapMessage); SOAPFault soapFault = body.addFault(); SOAPFaultException sf = (SOAPFaultException)exception; soapFault.setFaultString(sf.getFault().getFaultString()); SAAJUtils.setFaultCode(soapFault, sf.getFault().getFaultCodeAsQName()); soapFault.setFaultActor(sf.getFault().getFaultActor()); if (sf.getFault().hasDetail()) { SoapFault sf = SoapFault.createFault((Fault)exception, ((SoapMessage)msg).getVersion()); soapFault.setFaultString(sf.getReason()); SAAJUtils.setFaultCode(soapFault, sf.getFaultCode()); if (sf.hasDetails()) { soapFault.addDetail(); SAAJUtils.setFaultCode(soapFault, new QName("http://cxf.apache.org/faultcode", "HandlerFault")); soapFault.setFaultString(exception.getMessage());
public void handleMessage(SoapMessage message) { if (binding.getHandlerChain().isEmpty()) { return; } if (getInvoker(message).getProtocolHandlers().isEmpty()) { return; } checkUnderstoodHeaders(message); if (getInvoker(message).isOutbound()) { //The SOAPMessage might be set from the outchain, in this case, //we need to clean it up and create a new SOAPMessage dedicated to fault. message.setContent(SOAPMessage.class, null); SAAJ_OUT.handleMessage(message); message.getInterceptorChain().add(ending); } }
public SOAPMessage getMessage() { SOAPMessage message = null; if (getWrappedMessage().getContent(Object.class) instanceof SOAPMessage) { message = (SOAPMessage)getWrappedMessage().getContent(Object.class); } else { message = getWrappedMessage().getContent(SOAPMessage.class); } //Only happens to non-Dispatch/Provider case. if (null == message) { Boolean outboundProperty = (Boolean)get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty == null || !outboundProperty) { //No SOAPMessage exists yet, so lets create one SAAJ_IN.handleMessage(getWrappedSoapMessage()); message = getWrappedSoapMessage().getContent(SOAPMessage.class); } } return message; }
public void handleFault(SoapMessage message) { if (binding.getHandlerChain().isEmpty()) { return; } if (getInvoker(message).getProtocolHandlers().isEmpty()) { return; } if (getInvoker(message).isOutbound() && !chainAlreadyContainsSAAJ(message)) { SAAJ_OUT.handleFault(message); } }
soapFault = SAAJFactoryResolver.createSOAPFactory(null).createFault(); } catch (Throwable t) { SAAJUtils.setFaultCode(soapFault, ((SoapFault)ex).getFaultCode()); String role = ((SoapFault)ex).getRole(); if (role != null) {
List<SOAPElement> params = new ArrayList<>(); message.put(MessageContext.REFERENCE_PARAMETERS, params); SOAPHeader head = SAAJUtils.getHeader(msg); if (head != null) { Iterator<Node> it = CastUtils.cast(head.getChildElements());
SOAPFaultException sf = (SOAPFaultException)exception; soapFault.setFaultString(sf.getFault().getFaultString()); SAAJUtils.setFaultCode(soapFault, sf.getFault().getFaultCodeAsQName()); soapFault.setFaultActor(sf.getFault().getFaultActor()); if (sf.getFault().hasDetail()) { .getVersion()); soapFault.setFaultString(sf.getReason()); SAAJUtils.setFaultCode(soapFault, sf.getFaultCode()); if (sf.hasDetails()) { soapFault.addDetail(); SAAJUtils.setFaultCode(soapFault, new QName("http://cxf.apache.org/faultcode", "HandleFault"));
getOutInterceptors().add(new SwAOutInterceptor()); if (isProvider && mode == Mode.MESSAGE) { in.add(new SAAJInInterceptor()); SAAJOutInterceptor saajOut = new SAAJOutInterceptor(); out.add(saajOut); out.add(new MessageModeOutInterceptor(saajOut,
protected QName getOpQName(Exchange ex, Object data) { SOAPMessageContextImpl sm = (SOAPMessageContextImpl)data; try { SOAPMessage msg = sm.getMessage(); if (msg == null) { return null; } SOAPBody body = SAAJUtils.getBody(msg); if (body == null) { return null; } org.w3c.dom.Node nd = body.getFirstChild(); while (nd != null && !(nd instanceof org.w3c.dom.Element)) { nd = nd.getNextSibling(); } if (nd != null) { return new QName(nd.getNamespaceURI(), nd.getLocalName()); } } catch (SOAPException e) { //ignore, nothing we can do } return null; }
public void handleFault(SoapMessage message) { saajOut.handleFault(message); }
private SOAPMessage initSOAPMessage(InputStream is) throws SOAPException, IOException { SOAPMessage msg = null; if (is != null) { msg = SAAJFactoryResolver.createMessageFactory(null).createMessage(null, is); } else { msg = SAAJFactoryResolver.createMessageFactory(null).createMessage(); } msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true"); msg.getSOAPPart().getEnvelope().addNamespaceDeclaration(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD); msg.getSOAPPart().getEnvelope().addNamespaceDeclaration(WSDLConstants.NP_SCHEMA_XSI, WSDLConstants.NS_SCHEMA_XSI); return msg; } }
if (m != null && !MessageUtils.isOutbound(message)) { try { SAAJUtils.getBody(m).removeContents(); W3CDOMStreamWriter writer = new W3CDOMStreamWriter(SAAJUtils.getBody(m)); StaxUtils.copy(s, writer); writer.flush(); s = new DOMSource(m.getSOAPPart()); } else { s = new DOMSource(SAAJUtils.getBody(m).getFirstChild()); W3CDOMStreamReader r = new W3CDOMStreamReader(DOMUtils.getFirstElement(SAAJUtils.getBody(m))); message.setContent(XMLStreamReader.class, r); } catch (Exception e) { write(s, SAAJUtils.getBody(msg)); s = new DOMSource(msg.getSOAPPart()); } catch (Exception e) {
InputStream in = cos.getInputStream(); SOAPMessage msg = initSOAPMessage(in); source = new DOMSource(SAAJUtils.getBody(msg).getFirstChild()); in.close(); } catch (Exception e) {
if (msg != null) { try { Node node = SAAJUtils.getBody(msg).getFirstChild(); while (node != null && !(node instanceof Element)) { node = node.getNextSibling();