A method to parse a SOAP 1.2 fault message.

@param soapMessage
the SOAP 1.2 fault message to parse

@param logger
the PrintWriter to log all results to

@return void

@author Simone Gianfranceschi
557429
private void parseSoap12Fault(Document soapMessage, PrintWriter logger)
            throws Exception {
        Element envelope = soapMessage.getDocumentElement();
        Element code = DomUtils.getElementByTagNameNS(envelope,
                SOAP_12_NAMESPACE, "Code");
        String value = DomUtils.getElementByTagNameNS(code, SOAP_12_NAMESPACE,
                "Value").getTextContent();
        String msg = "SOAP Fault received - [code:" + value + "]";
        Element subCode = DomUtils.getElementByTagNameNS(code,
                SOAP_12_NAMESPACE, "Subcode");
        if (subCode != null) {
            value = DomUtils.getElementByTagNameNS(subCode, SOAP_12_NAMESPACE,
                    "Value").getTextContent();
            msg += "[subcode:" + value + "]";
        }
        Element reason = DomUtils.getElementByTagNameNS(envelope,
                SOAP_12_NAMESPACE, "Reason");
        Element text = DomUtils.getElementByTagNameNS(reason,
                SOAP_12_NAMESPACE, "Text");
        if (text != null) {
            value = text.getTextContent();
            msg += "[reason:" + value + "]";
        }

        logger.println(msg);
    }
339056
public void debug(String msg) {
        if (!logger.isDebugEnabled())
            return;

        if (instanceofLAL) {
            ((LocationAwareLogger) logger).log(null, fqcn, LocationAwareLogger.DEBUG_INT, msg, null, null);
        } else {
            logger.debug(msg);
        }
    }
451951
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
        try {
            logRequest("Sending SOAP request", messageContext, false);
        } catch (SoapEnvelopeException e) {
            log.warn("Unable to write SOAP request to logger", e);
        } catch (TransformerException e) {
            log.warn("Unable to write SOAP request to logger", e);
        }
        
        return true;
    }
508946
protected void handleInboundAttachments(final org.springframework.ws.soap.SoapMessage soapMessage,
                                            final SoapMessage message) {
        final Iterator<Attachment> attachments = soapMessage.getAttachments();

        while (attachments.hasNext()) {
            final Attachment attachment = attachments.next();
            final SoapAttachment soapAttachment = SoapAttachment.from(attachment);

            if (log.isDebugEnabled()) {
                log.debug(String.format("SOAP message contains attachment with contentId '%s'", soapAttachment.getContentId()));
            }

            message.addAttachment(soapAttachment);
        }
    }
735907
public static void log(Logger logger,
                           Level level,
                           String message,
                           Object[] parameters) {
        if (logger.isLoggable(level)) {
            String msg = localize(logger, message);
            try {
                msg = MessageFormat.format(msg, parameters);
            } catch (IllegalArgumentException ex) {
                //ignore, log as is
            }
            doLog(logger, level, msg, null);
        }
    }
1197399
protected void logSoapMessage(String logMessage, SoapMessage soapMessage, boolean incoming) throws TransformerException {
        Transformer transformer = createIndentingTransformer();
        StringWriter writer = new StringWriter();
        
        transformer.transform(soapMessage.getEnvelope().getSource(), new StreamResult(writer));
        logMessage(logMessage, XMLUtils.prettyPrint(writer.toString()), incoming);
    }
340901
public String getMessageVersion(BaseMessage externalMessage)
    {
        String version = null;
        if (!(externalMessage.getExternalMessage() instanceof SoapTrxMessageIn))
            return null;
        SOAPMessage message = (SOAPMessage)((SoapTrxMessageIn)externalMessage.getExternalMessage()).getRawData();
        try {
            // Message creation takes care of creating the SOAPPart - a
            // required part of the message as per the SOAP 1.1
            // specification.
            SOAPPart sp = message.getSOAPPart();
            
            // Retrieve the envelope from the soap part to start building
            // the soap message.
            SOAPEnvelope envelope = sp.getEnvelope();
            
            // Create a soap header from the envelope.
            //?SOAPHeader hdr = envelope.getHeader();
            
            // Get the body
            SOAPBody body = envelope.getBody();
            SOAPElement element = this.getElement(body, null);
            if (element != null)
            {
                QName na = new QName("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
                String attribute = element.getAttributeValue(na);
                if (attribute != null)
                {
                    Record recMessageControl = this.getRecord(MessageControlModel.MESSAGE_CONTROL_FILE);
                    if (recMessageControl == null)
                        recMessageControl = Record.makeRecordFromClassName(MessageControlModel.THICK_CLASS, this);
                    version = ((MessageControlModel)recMessageControl).getVersionFromSchemaLocation(attribute);
                }
            }
        } catch(Throwable ex) {
            ex.printStackTrace();
        }
        if (version != null)
            return version;
        return super.getMessageVersion(externalMessage);    // No type found.
    }
43826
@DefinedBy(Api.ANNOTATION_PROCESSING)
    public void printMessage(Diagnostic.Kind kind, CharSequence msg) {
        printMessage(kind, msg, null, null, null);
    }
565678
public static Messaging getMessaging(final Jaxb2Marshaller jaxb2Marshaller, final WebServiceMessage message) {

        SoapHeader soapHeader = ((SoapMessage) message).getSoapHeader();
        if (soapHeader == null) {
            throw new RuntimeException("The ebMS header is missing (no SOAP header found in SOAP request)");
        }

        Iterator<SoapHeaderElement> soapHeaderElementIterator = soapHeader.examineHeaderElements(MESSAGING_QNAME);
        if (!soapHeaderElementIterator.hasNext()) {
            throw new RuntimeException("The ebMS header is missing in SOAP header");
        }

        SoapHeaderElement incomingSoapHeaderElement = soapHeaderElementIterator.next();
        try {
            return (Messaging) jaxb2Marshaller.unmarshal(incomingSoapHeaderElement.getSource());
        } catch (Exception e) {
            throw new RuntimeException("The ebMs header failed to unmarshall");
        }

    }
28401
@Override
    public void handleMessage(final Message message) throws Fault {
        final InputStream is = message.getContent(InputStream.class);
        if (WireTapHelper.isMessageContentToBeLogged(message, logMessageContent, logMessageContentOverride)) {
            if (null == is) {
                Reader reader = message.getContent(Reader.class);
                if (null != reader) {
                    String encoding = (String) message.get(Message.ENCODING);
                    if (encoding == null) {
                        encoding = "UTF-8";
                    }
                    try {
                        final CachedOutputStream cos = new CachedOutputStream();
                        final Writer writer = new OutputStreamWriter(cos, encoding);
                        IOUtils.copy(reader, writer, 1024);
                        reader.reset();
                        writer.flush();
                        message.setContent(InputStream.class, cos.getInputStream());
                        message.setContent(Reader.class, null);
                        message.setContent(CachedOutputStream.class, cos);
                        closeCachedOutputStream(message, cos);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    } finally {
                        try {
                            reader.reset();
                        } catch (IOException e) {
                        }
                    }
                }
            } else {
                try {
                    final CachedOutputStream cos = new CachedOutputStream();
                    // TODO: We should try to make this streaming
                    //WireTapInputStream wtis = new WireTapInputStream(is, cos);
                    //message.setContent(InputStream.class, wtis);
                    IOUtils.copyAndCloseInput(is, cos);
                    message.setContent(InputStream.class, cos.getInputStream());
                    message.setContent(CachedOutputStream.class, cos);
                    closeCachedOutputStream(message, cos);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }else {
            try {
                final CachedOutputStream cos = new CachedOutputStream();
                cos.write(WireTapHelper.CONTENT_LOGGING_IS_DISABLED.getBytes(Charset.forName("UTF-8")));
                message.setContent(CachedOutputStream.class, cos);
                message.setContent(InputStream.class, is);
                closeCachedOutputStream(message, cos);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
62929
public void handleMessage(T message) throws Fault {
        if (LOG.isLoggable(Level.FINEST)) {
            LOG.finest("FlowIdProducerOut Interceptor called. isOutbound: "
                    + MessageUtils.isOutbound(message) + ", isRequestor: "
                    + MessageUtils.isRequestor(message));
        }

        if (MessageUtils.isRequestor(message)) {
            handleRequestOut(message);
        } else {
            handleResponseOut(message);
        }

        // Don't write flowId for Oneway responses
        if (isOnewayResponse(message)) {
            return;
        }

        // write FlowId to HTTP and Soap layer
        String flowId = FlowIdHelper.getFlowId(message);
        FlowIdProtocolHeaderCodec.writeFlowId(message, flowId);
        FlowIdSoapCodec.writeFlowId(message, flowId);

    }
1152185
@Override
    protected void log(final String msg) {
        if (config.getLogLevel().equals(LogLevel.DEBUG)) {
            logger.debug(msg);
        } else if (config.getLogLevel().equals(LogLevel.TRACE)) {
            logger.trace(msg);
        } else if (config.getLogLevel().equals(LogLevel.INFO)) {
            logger.info(msg);
        } else if (config.getLogLevel().equals(LogLevel.WARN)) {
            logger.warn(msg);
        } else if (config.getLogLevel().equals(LogLevel.ERROR)) {
            logger.error(msg);
        }
    }
1037252
def soap_fault(message=None, actor=None, code=None, detail=None):
    
    _string = _actor = _code = _detail = None

    if message:
        _string = soapenv.Fault_faultstring(text=message)
    if actor:
        _actor = soapenv.Fault_faultactor(text=actor)
    if code:
        _code = soapenv.Fault_faultcode(text=code)
    if detail:
        _detail = soapenv.Fault_detail(text=detail)

    fault = soapenv.Fault(
        faultcode=_code,
        faultstring=_string,
        faultactor=_actor,
        detail=_detail,
    )

    return "%s" % fault
906407
public static void w(String msg, Element element) {
		messager.printMessage(Diagnostic.Kind.WARNING, msg, element);
	}
1069376
public function logMessage(Message $message) {
        foreach($this->logger as $logger) {
            $logger->logMessage($message);
        }
    }
159270
@Override
    public void handleMessage(Message message) throws Fault {
        String method = (String) message.get(Message.HTTP_REQUEST_METHOD);
        String query = (String) message.get(Message.QUERY_STRING);
        if (!"GET".equals(method) || StringUtils.isEmpty(query)) {
            return;
        }
        String baseUri = (String) message.get(Message.REQUEST_URL);
        String ctx = (String) message.get(Message.PATH_INFO);

        //cannot have two wsdl's being written for the same endpoint at the same
        //time as the addresses may get mixed up
        synchronized (message.getExchange().getEndpoint()) {
            Map<String, String> map = UrlUtils.parseQueryString(query);
            if (isRecognizedQuery(map, baseUri, ctx,
                                  message.getExchange().getEndpoint().getEndpointInfo())) {

                try {
                    Conduit c = message.getExchange().getDestination().getBackChannel(message, null, null);
                    Message mout = new MessageImpl();
                    mout.setExchange(message.getExchange());
                    message.getExchange().setOutMessage(mout);
                    //Customize the response to 404
                    mout.put(Message.RESPONSE_CODE, HttpURLConnection.HTTP_NOT_FOUND);
                    mout.put(Message.CONTENT_TYPE, "text/xml");
                    c.prepare(mout);
                    OutputStream os = mout.getContent(OutputStream.class);

                    Document doc = getDocument(message,
                                               baseUri,
                                               map,
                                               ctx,
                                               message.getExchange().getEndpoint().getEndpointInfo());

                    String enc = null;
                    try {
                        enc = doc.getXmlEncoding();
                    } catch (Exception ex) {
                        //ignore - not dom level 3
                    }
                    if (enc == null) {
                        enc = "utf-8";
                    }

                    XMLStreamWriter writer = null;
                    try {
                        writer = StaxUtils.createXMLStreamWriter(os, enc);
                        StaxUtils.writeNode(doc, writer, true);
                        message.getInterceptorChain().abort();
                        writer.flush();
                        os.flush();
                    } catch (IOException ex) {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isInfoEnabled()) {
                            Tr.info(tc, "error.write.wsdl.stream", ex);
                        }
                        //LOG.log(Level.FINE, "Failure writing full wsdl to the stream", ex);
                        //we can ignore this.   Likely, whatever has requested the WSDL
                        //has closed the connection before reading the entire wsdl.  
                        //WSDL4J has a tendency to not read the closing tags and such
                        //and thus can sometimes hit this.   In anycase, it's 
                        //pretty much ignorable and nothing we can do about it (cannot
                        //send a fault or anything anyway
                    } finally {
                        if (writer != null) {
                            try {
                                writer.close();
                            } catch (Exception e) {
                            }
                        }
                        try {
                            os.close();
                        } catch (Exception e) {
                        }
                    }
                } catch (IOException e) {
                    throw new Fault(e);
                } catch (XMLStreamException e) {
                    throw new Fault(e);
                } finally {
                    message.getExchange().setOutMessage(null);
                }
            }
        }
    }
1205465
public static void validateMessage(String basePath, Document wsdl, SOAPMessage msg) throws XSDFormatException, XSDValidationException{
        LOG.debug("Validating message on WSDL");

        //get schema
        //Element schemaNode = (Element)wsdl.getElementsByTagNameNS(XMLConstants"http://www.w3.org/2001/XMLSchema","schema").item(0);
        NodeList schemaNodes = wsdl.getElementsByTagNameNS(
                XMLConstants.W3C_XML_SCHEMA_NS_URI, "schema");

        int nrSchemas = schemaNodes.getLength();

        Source[] schemas = new Source[nrSchemas];

        for (int i = 0; i < nrSchemas; i++) {
            schemas[i] = new DOMSource(schemaNodes.item(i));
        }

        //get body
        Element body = null;
        try {
            body = msg.getSOAPBody();
        } catch (SOAPException e) {
            throw S1SystemError.wrap(e);
        }

        if(msg.getAttachments().hasNext()){
            //copy
            body = (Element)body.cloneNode(true);
            //remove xop:Includes
            NodeList nl = body.getElementsByTagNameNS("http://www.w3.org/2004/08/xop/include","Include");
            for(int i=0;i<nl.getLength();i++){
                Node n = nl.item(i);
                n.getParentNode().removeChild(n);
            }
        }

        //validate Body children
        for(Element el:XMLFormat.getChildElementList(body,null,null)){
            XMLFormat.validate(basePath, schemas, el);
        }
    }