com.sun.xml.internal.ws.util.DOMUtil Java Examples

The following examples show how to use com.sun.xml.internal.ws.util.DOMUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SAAJMessage.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected void access() {
    if (!accessedMessage) {
        try {
            envelopeAttrs = sm.getSOAPPart().getEnvelope().getAttributes();
            Node body = sm.getSOAPBody();
            bodyAttrs = body.getAttributes();
            soapVersion = SOAPVersion.fromNsUri(body.getNamespaceURI());
            //cature all the body elements
            bodyParts = DOMUtil.getChildElements(body);
            //we treat payload as the first body part
            payload = bodyParts.size() > 0 ? bodyParts.get(0) : null;
            // hope this is correct. Caching the localname and namespace of the payload should be fine
            // but what about if a Handler replaces the payload with something else? Weel, may be it
            // will be error condition anyway
            if (payload != null) {
                payloadLocalName = payload.getLocalName();
                payloadNamespace = payload.getNamespaceURI();
            }
            accessedMessage = true;
        } catch (SOAPException e) {
            throw new WebServiceException(e);
        }
    }
}
 
Example #2
Source File: SOAP11Fault.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This constructor takes soap fault detail among other things. The detail could represent {@link javax.xml.soap.Detail}
 * or a java object that can be marshalled/unmarshalled by JAXB.
 *
 * @param code
 * @param reason
 * @param actor
 * @param detailObject
 */
SOAP11Fault(QName code, String reason, String actor, Element detailObject) {
    this.faultcode = code;
    this.faultstring = reason;
    this.faultactor = actor;
    if (detailObject != null) {
        if ((detailObject.getNamespaceURI() == null ||
             "".equals(detailObject.getNamespaceURI())) && "detail".equals(detailObject.getLocalName())) {
            detail = new DetailType();
            for(Element detailEntry : DOMUtil.getChildElements(detailObject)) {
                detail.getDetails().add(detailEntry);
            }
        } else {
            detail = new DetailType(detailObject);
        }
    }
}
 
Example #3
Source File: SOAP12Fault.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
SOAP12Fault(CodeType code, ReasonType reason, String node, String role, Element detailObject) {
    this.code = code;
    this.reason = reason;
    this.node = node;
    this.role = role;
    if (detailObject != null) {
        if(detailObject.getNamespaceURI().equals(ns) && detailObject.getLocalName().equals("Detail")){
            detail = new DetailType();
            for(Element detailEntry : DOMUtil.getChildElements(detailObject)){
                detail.getDetails().add(detailEntry);
            }
        }else{
            detail = new DetailType(detailObject);
        }
    }
}
 
Example #4
Source File: SAAJMessage.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected void access() {
    if (!accessedMessage) {
        try {
            envelopeAttrs = sm.getSOAPPart().getEnvelope().getAttributes();
            Node body = sm.getSOAPBody();
            bodyAttrs = body.getAttributes();
            soapVersion = SOAPVersion.fromNsUri(body.getNamespaceURI());
            //cature all the body elements
            bodyParts = DOMUtil.getChildElements(body);
            //we treat payload as the first body part
            payload = bodyParts.size() > 0 ? bodyParts.get(0) : null;
            // hope this is correct. Caching the localname and namespace of the payload should be fine
            // but what about if a Handler replaces the payload with something else? Weel, may be it
            // will be error condition anyway
            if (payload != null) {
                payloadLocalName = payload.getLocalName();
                payloadNamespace = payload.getNamespaceURI();
            }
            accessedMessage = true;
        } catch (SOAPException e) {
            throw new WebServiceException(e);
        }
    }
}
 
Example #5
Source File: SOAPFaultBuilder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DOM node that represents the complete stack trace of the exception,
 * and attach that to {@link DetailType}.
 */
final void captureStackTrace(@Nullable Throwable t) {
    if(t==null)     return;
    if(!captureStackTrace)  return;     // feature disabled

    try {
        Document d = DOMUtil.createDom();
        ExceptionBean.marshal(t,d);

        DetailType detail = getDetail();
        if(detail==null)
        setDetail(detail=new DetailType());

        detail.getDetails().add(d.getDocumentElement());
    } catch (JAXBException e) {
        // this should never happen
        logger.log(Level.WARNING, "Unable to capture the stack trace into XML",e);
    }
}
 
Example #6
Source File: SOAP12Fault.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
SOAP12Fault(CodeType code, ReasonType reason, String node, String role, Element detailObject) {
    this.code = code;
    this.reason = reason;
    this.node = node;
    this.role = role;
    if (detailObject != null) {
        if(detailObject.getNamespaceURI().equals(ns) && detailObject.getLocalName().equals("Detail")){
            detail = new DetailType();
            for(Element detailEntry : DOMUtil.getChildElements(detailObject)){
                detail.getDetails().add(detailEntry);
            }
        }else{
            detail = new DetailType(detailObject);
        }
    }
}
 
Example #7
Source File: SOAP11Fault.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This constructor takes soap fault detail among other things. The detail could represent {@link javax.xml.soap.Detail}
 * or a java object that can be marshalled/unmarshalled by JAXB.
 *
 * @param code
 * @param reason
 * @param actor
 * @param detailObject
 */
SOAP11Fault(QName code, String reason, String actor, Element detailObject) {
    this.faultcode = code;
    this.faultstring = reason;
    this.faultactor = actor;
    if (detailObject != null) {
        if ((detailObject.getNamespaceURI() == null ||
             "".equals(detailObject.getNamespaceURI())) && "detail".equals(detailObject.getLocalName())) {
            detail = new DetailType();
            for(Element detailEntry : DOMUtil.getChildElements(detailObject)) {
                detail.getDetails().add(detailEntry);
            }
        } else {
            detail = new DetailType(detailObject);
        }
    }
}
 
Example #8
Source File: SOAP12Fault.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
SOAP12Fault(CodeType code, ReasonType reason, String node, String role, Element detailObject) {
    this.code = code;
    this.reason = reason;
    this.node = node;
    this.role = role;
    if (detailObject != null) {
        if(detailObject.getNamespaceURI().equals(ns) && detailObject.getLocalName().equals("Detail")){
            detail = new DetailType();
            for(Element detailEntry : DOMUtil.getChildElements(detailObject)){
                detail.getDetails().add(detailEntry);
            }
        }else{
            detail = new DetailType(detailObject);
        }
    }
}
 
Example #9
Source File: SOAPFaultBuilder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DOM node that represents the complete stack trace of the exception,
 * and attach that to {@link DetailType}.
 */
final void captureStackTrace(@Nullable Throwable t) {
    if(t==null)     return;
    if(!captureStackTrace)  return;     // feature disabled

    try {
        Document d = DOMUtil.createDom();
        ExceptionBean.marshal(t,d);

        DetailType detail = getDetail();
        if(detail==null)
        setDetail(detail=new DetailType());

        detail.getDetails().add(d.getDocumentElement());
    } catch (JAXBException e) {
        // this should never happen
        logger.log(Level.WARNING, "Unable to capture the stack trace into XML",e);
    }
}
 
Example #10
Source File: SAAJMessage.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected void access() {
    if (!accessedMessage) {
        try {
            envelopeAttrs = sm.getSOAPPart().getEnvelope().getAttributes();
            Node body = sm.getSOAPBody();
            bodyAttrs = body.getAttributes();
            soapVersion = SOAPVersion.fromNsUri(body.getNamespaceURI());
            //cature all the body elements
            bodyParts = DOMUtil.getChildElements(body);
            //we treat payload as the first body part
            payload = bodyParts.size() > 0 ? bodyParts.get(0) : null;
            // hope this is correct. Caching the localname and namespace of the payload should be fine
            // but what about if a Handler replaces the payload with something else? Weel, may be it
            // will be error condition anyway
            if (payload != null) {
                payloadLocalName = payload.getLocalName();
                payloadNamespace = payload.getNamespaceURI();
            }
            accessedMessage = true;
        } catch (SOAPException e) {
            throw new WebServiceException(e);
        }
    }
}
 
Example #11
Source File: SAAJMessage.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected void access() {
    if (!accessedMessage) {
        try {
            envelopeAttrs = sm.getSOAPPart().getEnvelope().getAttributes();
            Node body = sm.getSOAPBody();
            bodyAttrs = body.getAttributes();
            soapVersion = SOAPVersion.fromNsUri(body.getNamespaceURI());
            //cature all the body elements
            bodyParts = DOMUtil.getChildElements(body);
            //we treat payload as the first body part
            payload = bodyParts.size() > 0 ? bodyParts.get(0) : null;
            // hope this is correct. Caching the localname and namespace of the payload should be fine
            // but what about if a Handler replaces the payload with something else? Weel, may be it
            // will be error condition anyway
            if (payload != null) {
                payloadLocalName = payload.getLocalName();
                payloadNamespace = payload.getNamespaceURI();
            }
            accessedMessage = true;
        } catch (SOAPException e) {
            throw new WebServiceException(e);
        }
    }
}
 
Example #12
Source File: SOAPFaultBuilder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DOM node that represents the complete stack trace of the exception,
 * and attach that to {@link DetailType}.
 */
final void captureStackTrace(@Nullable Throwable t) {
    if(t==null)     return;
    if(!captureStackTrace)  return;     // feature disabled

    try {
        Document d = DOMUtil.createDom();
        ExceptionBean.marshal(t,d);

        DetailType detail = getDetail();
        if(detail==null)
        setDetail(detail=new DetailType());

        detail.getDetails().add(d.getDocumentElement());
    } catch (JAXBException e) {
        // this should never happen
        logger.log(Level.WARNING, "Unable to capture the stack trace into XML",e);
    }
}
 
Example #13
Source File: SOAP12Fault.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
SOAP12Fault(CodeType code, ReasonType reason, String node, String role, Element detailObject) {
    this.code = code;
    this.reason = reason;
    this.node = node;
    this.role = role;
    if (detailObject != null) {
        if(detailObject.getNamespaceURI().equals(ns) && detailObject.getLocalName().equals("Detail")){
            detail = new DetailType();
            for(Element detailEntry : DOMUtil.getChildElements(detailObject)){
                detail.getDetails().add(detailEntry);
            }
        }else{
            detail = new DetailType(detailObject);
        }
    }
}
 
Example #14
Source File: SAAJMessage.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void access() {
    if (!accessedMessage) {
        try {
            envelopeAttrs = sm.getSOAPPart().getEnvelope().getAttributes();
            Node body = sm.getSOAPBody();
            bodyAttrs = body.getAttributes();
            soapVersion = SOAPVersion.fromNsUri(body.getNamespaceURI());
            //cature all the body elements
            bodyParts = DOMUtil.getChildElements(body);
            //we treat payload as the first body part
            payload = bodyParts.size() > 0 ? bodyParts.get(0) : null;
            // hope this is correct. Caching the localname and namespace of the payload should be fine
            // but what about if a Handler replaces the payload with something else? Weel, may be it
            // will be error condition anyway
            if (payload != null) {
                payloadLocalName = payload.getLocalName();
                payloadNamespace = payload.getNamespaceURI();
            }
            accessedMessage = true;
        } catch (SOAPException e) {
            throw new WebServiceException(e);
        }
    }
}
 
Example #15
Source File: SOAPFaultBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DOM node that represents the complete stack trace of the exception,
 * and attach that to {@link DetailType}.
 */
final void captureStackTrace(@Nullable Throwable t) {
    if(t==null)     return;
    if(!captureStackTrace)  return;     // feature disabled

    try {
        Document d = DOMUtil.createDom();
        ExceptionBean.marshal(t,d);

        DetailType detail = getDetail();
        if(detail==null)
        setDetail(detail=new DetailType());

        detail.getDetails().add(d.getDocumentElement());
    } catch (JAXBException e) {
        // this should never happen
        logger.log(Level.WARNING, "Unable to capture the stack trace into XML",e);
    }
}
 
Example #16
Source File: SAAJMessage.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void access() {
    if (!accessedMessage) {
        try {
            envelopeAttrs = sm.getSOAPPart().getEnvelope().getAttributes();
            Node body = sm.getSOAPBody();
            bodyAttrs = body.getAttributes();
            soapVersion = SOAPVersion.fromNsUri(body.getNamespaceURI());
            //cature all the body elements
            bodyParts = DOMUtil.getChildElements(body);
            //we treat payload as the first body part
            payload = bodyParts.size() > 0 ? bodyParts.get(0) : null;
            // hope this is correct. Caching the localname and namespace of the payload should be fine
            // but what about if a Handler replaces the payload with something else? Weel, may be it
            // will be error condition anyway
            if (payload != null) {
                payloadLocalName = payload.getLocalName();
                payloadNamespace = payload.getNamespaceURI();
            }
            accessedMessage = true;
        } catch (SOAPException e) {
            throw new WebServiceException(e);
        }
    }
}
 
Example #17
Source File: SOAP12Fault.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
SOAP12Fault(CodeType code, ReasonType reason, String node, String role, Element detailObject) {
    this.code = code;
    this.reason = reason;
    this.node = node;
    this.role = role;
    if (detailObject != null) {
        if(detailObject.getNamespaceURI().equals(ns) && detailObject.getLocalName().equals("Detail")){
            detail = new DetailType();
            for(Element detailEntry : DOMUtil.getChildElements(detailObject)){
                detail.getDetails().add(detailEntry);
            }
        }else{
            detail = new DetailType(detailObject);
        }
    }
}
 
Example #18
Source File: SOAPFaultBuilder.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DOM node that represents the complete stack trace of the exception,
 * and attach that to {@link DetailType}.
 */
final void captureStackTrace(@Nullable Throwable t) {
    if(t==null)     return;
    if(!captureStackTrace)  return;     // feature disabled

    try {
        Document d = DOMUtil.createDom();
        ExceptionBean.marshal(t,d);

        DetailType detail = getDetail();
        if(detail==null)
        setDetail(detail=new DetailType());

        detail.getDetails().add(d.getDocumentElement());
    } catch (JAXBException e) {
        // this should never happen
        logger.log(Level.WARNING, "Unable to capture the stack trace into XML",e);
    }
}
 
Example #19
Source File: SOAPFaultBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DOM node that represents the complete stack trace of the exception,
 * and attach that to {@link DetailType}.
 */
final void captureStackTrace(@Nullable Throwable t) {
    if(t==null)     return;
    if(!captureStackTrace)  return;     // feature disabled

    try {
        Document d = DOMUtil.createDom();
        ExceptionBean.marshal(t,d);

        DetailType detail = getDetail();
        if(detail==null)
        setDetail(detail=new DetailType());

        detail.getDetails().add(d.getDocumentElement());
    } catch (JAXBException e) {
        // this should never happen
        logger.log(Level.WARNING, "Unable to capture the stack trace into XML",e);
    }
}
 
Example #20
Source File: SOAP11Fault.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This constructor takes soap fault detail among other things. The detail could represent {@link javax.xml.soap.Detail}
 * or a java object that can be marshalled/unmarshalled by JAXB.
 *
 * @param code
 * @param reason
 * @param actor
 * @param detailObject
 */
SOAP11Fault(QName code, String reason, String actor, Element detailObject) {
    this.faultcode = code;
    this.faultstring = reason;
    this.faultactor = actor;
    if (detailObject != null) {
        if ((detailObject.getNamespaceURI() == null ||
             "".equals(detailObject.getNamespaceURI())) && "detail".equals(detailObject.getLocalName())) {
            detail = new DetailType();
            for(Element detailEntry : DOMUtil.getChildElements(detailObject)) {
                detail.getDetails().add(detailEntry);
            }
        } else {
            detail = new DetailType(detailObject);
        }
    }
}
 
Example #21
Source File: SAAJMessage.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected void access() {
    if (!accessedMessage) {
        try {
            envelopeAttrs = sm.getSOAPPart().getEnvelope().getAttributes();
            Node body = sm.getSOAPBody();
            bodyAttrs = body.getAttributes();
            soapVersion = SOAPVersion.fromNsUri(body.getNamespaceURI());
            //cature all the body elements
            bodyParts = DOMUtil.getChildElements(body);
            //we treat payload as the first body part
            payload = bodyParts.size() > 0 ? bodyParts.get(0) : null;
            // hope this is correct. Caching the localname and namespace of the payload should be fine
            // but what about if a Handler replaces the payload with something else? Weel, may be it
            // will be error condition anyway
            if (payload != null) {
                payloadLocalName = payload.getLocalName();
                payloadNamespace = payload.getNamespaceURI();
            }
            accessedMessage = true;
        } catch (SOAPException e) {
            throw new WebServiceException(e);
        }
    }
}
 
Example #22
Source File: SOAPFaultBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a DOM node that represents the complete stack trace of the exception,
 * and attach that to {@link DetailType}.
 */
final void captureStackTrace(@Nullable Throwable t) {
    if(t==null)     return;
    if(!captureStackTrace)  return;     // feature disabled

    try {
        Document d = DOMUtil.createDom();
        ExceptionBean.marshal(t,d);

        DetailType detail = getDetail();
        if(detail==null)
        setDetail(detail=new DetailType());

        detail.getDetails().add(d.getDocumentElement());
    } catch (JAXBException e) {
        // this should never happen
        logger.log(Level.WARNING, "Unable to capture the stack trace into XML",e);
    }
}
 
Example #23
Source File: SOAP11Fault.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This constructor takes soap fault detail among other things. The detail could represent {@link javax.xml.soap.Detail}
 * or a java object that can be marshalled/unmarshalled by JAXB.
 *
 * @param code
 * @param reason
 * @param actor
 * @param detailObject
 */
SOAP11Fault(QName code, String reason, String actor, Element detailObject) {
    this.faultcode = code;
    this.faultstring = reason;
    this.faultactor = actor;
    if (detailObject != null) {
        if ((detailObject.getNamespaceURI() == null ||
             "".equals(detailObject.getNamespaceURI())) && "detail".equals(detailObject.getLocalName())) {
            detail = new DetailType();
            for(Element detailEntry : DOMUtil.getChildElements(detailObject)) {
                detail.getDetails().add(detailEntry);
            }
        } else {
            detail = new DetailType(detailObject);
        }
    }
}
 
Example #24
Source File: Packet.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gives a list of Reference Parameters in the Message
 * <p>
 * Headers which have attribute wsa:IsReferenceParameter="true"
 * This is not cached as one may reset the Message.
 *<p>
 */
@Property(MessageContext.REFERENCE_PARAMETERS)
public
@NotNull
List<Element> getReferenceParameters() {
    Message msg = getMessage();
    List<Element> refParams = new ArrayList<Element>();
    if (msg == null) {
        return refParams;
    }
    MessageHeaders hl = msg.getHeaders();
    for (Header h : hl.asList()) {
        String attr = h.getAttribute(AddressingVersion.W3C.nsUri, "IsReferenceParameter");
        if (attr != null && (attr.equals("true") || attr.equals("1"))) {
            Document d = DOMUtil.createDom();
            SAX2DOMEx s2d = new SAX2DOMEx(d);
            try {
                h.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
                refParams.add((Element) d.getLastChild());
            } catch (SAXException e) {
                throw new WebServiceException(e);
            }
            /*
            DOMResult result = new DOMResult(d);
            XMLDOMWriterImpl domwriter = new XMLDOMWriterImpl(result);
            try {
                h.writeTo(domwriter);
                refParams.add((Element) result.getNode().getLastChild());
            } catch (XMLStreamException e) {
                throw new WebServiceException(e);
            }
            */
        }
    }
    return refParams;
}
 
Example #25
Source File: SAAJMessage.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException {
    access();
    try {
        for (Element part : bodyParts)
            DOMUtil.serializeNode(part, sw);
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
}
 
Example #26
Source File: Messages.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Message} from an {@link Element} that represents
 * the whole SOAP message.
 *
 * @param soapEnvelope
 *      The SOAP envelope element.
 */
public static Message create(Element soapEnvelope) {
    SOAPVersion ver = SOAPVersion.fromNsUri(soapEnvelope.getNamespaceURI());
    // find the headers
    Element header = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Header");
    HeaderList headers = null;
    if(header!=null) {
        for( Node n=header.getFirstChild(); n!=null; n=n.getNextSibling() ) {
            if(n.getNodeType()==Node.ELEMENT_NODE) {
                if(headers==null)
                    headers = new HeaderList(ver);
                headers.add(Headers.create((Element)n));
            }
        }
    }

    // find the payload
    Element body = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
    if(body==null)
        throw new WebServiceException("Message doesn't have <S:Body> "+soapEnvelope);
    Element payload = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");

    if(payload==null) {
        return new EmptyMessageImpl(headers, new AttachmentSetImpl(), ver);
    } else {
        return new DOMMessage(ver,headers,payload);
    }
}
 
Example #27
Source File: Messages.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Message} from an {@link Element} that represents
 * the whole SOAP message.
 *
 * @param soapEnvelope
 *      The SOAP envelope element.
 */
public static Message create(Element soapEnvelope) {
    SOAPVersion ver = SOAPVersion.fromNsUri(soapEnvelope.getNamespaceURI());
    // find the headers
    Element header = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Header");
    HeaderList headers = null;
    if(header!=null) {
        for( Node n=header.getFirstChild(); n!=null; n=n.getNextSibling() ) {
            if(n.getNodeType()==Node.ELEMENT_NODE) {
                if(headers==null)
                    headers = new HeaderList(ver);
                headers.add(Headers.create((Element)n));
            }
        }
    }

    // find the payload
    Element body = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
    if(body==null)
        throw new WebServiceException("Message doesn't have <S:Body> "+soapEnvelope);
    Element payload = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");

    if(payload==null) {
        return new EmptyMessageImpl(headers, new AttachmentSetImpl(), ver);
    } else {
        return new DOMMessage(ver,headers,payload);
    }
}
 
Example #28
Source File: Packet.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gives a list of Reference Parameters in the Message
 * <p>
 * Headers which have attribute wsa:IsReferenceParameter="true"
 * This is not cached as one may reset the Message.
 *<p>
 */
@Property(MessageContext.REFERENCE_PARAMETERS)
public
@NotNull
List<Element> getReferenceParameters() {
    Message msg = getMessage();
    List<Element> refParams = new ArrayList<Element>();
    if (msg == null) {
        return refParams;
    }
    MessageHeaders hl = msg.getHeaders();
    for (Header h : hl.asList()) {
        String attr = h.getAttribute(AddressingVersion.W3C.nsUri, "IsReferenceParameter");
        if (attr != null && (attr.equals("true") || attr.equals("1"))) {
            Document d = DOMUtil.createDom();
            SAX2DOMEx s2d = new SAX2DOMEx(d);
            try {
                h.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
                refParams.add((Element) d.getLastChild());
            } catch (SAXException e) {
                throw new WebServiceException(e);
            }
            /*
            DOMResult result = new DOMResult(d);
            XMLDOMWriterImpl domwriter = new XMLDOMWriterImpl(result);
            try {
                h.writeTo(domwriter);
                refParams.add((Element) result.getNode().getLastChild());
            } catch (XMLStreamException e) {
                throw new WebServiceException(e);
            }
            */
        }
    }
    return refParams;
}
 
Example #29
Source File: Messages.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Message} from an {@link Element} that represents
 * the whole SOAP message.
 *
 * @param soapEnvelope
 *      The SOAP envelope element.
 */
public static Message create(Element soapEnvelope) {
    SOAPVersion ver = SOAPVersion.fromNsUri(soapEnvelope.getNamespaceURI());
    // find the headers
    Element header = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Header");
    HeaderList headers = null;
    if(header!=null) {
        for( Node n=header.getFirstChild(); n!=null; n=n.getNextSibling() ) {
            if(n.getNodeType()==Node.ELEMENT_NODE) {
                if(headers==null)
                    headers = new HeaderList(ver);
                headers.add(Headers.create((Element)n));
            }
        }
    }

    // find the payload
    Element body = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
    if(body==null)
        throw new WebServiceException("Message doesn't have <S:Body> "+soapEnvelope);
    Element payload = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");

    if(payload==null) {
        return new EmptyMessageImpl(headers, new AttachmentSetImpl(), ver);
    } else {
        return new DOMMessage(ver,headers,payload);
    }
}
 
Example #30
Source File: Messages.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Message} from an {@link Element} that represents
 * the whole SOAP message.
 *
 * @param soapEnvelope
 *      The SOAP envelope element.
 */
public static Message create(Element soapEnvelope) {
    SOAPVersion ver = SOAPVersion.fromNsUri(soapEnvelope.getNamespaceURI());
    // find the headers
    Element header = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Header");
    HeaderList headers = null;
    if(header!=null) {
        for( Node n=header.getFirstChild(); n!=null; n=n.getNextSibling() ) {
            if(n.getNodeType()==Node.ELEMENT_NODE) {
                if(headers==null)
                    headers = new HeaderList(ver);
                headers.add(Headers.create((Element)n));
            }
        }
    }

    // find the payload
    Element body = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
    if(body==null)
        throw new WebServiceException("Message doesn't have <S:Body> "+soapEnvelope);
    Element payload = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");

    if(payload==null) {
        return new EmptyMessageImpl(headers, new AttachmentSetImpl(), ver);
    } else {
        return new DOMMessage(ver,headers,payload);
    }
}