Search in sources :

Example 1 with WsaMessageIDHeader

use of org.n52.shetland.w3c.wsa.WsaMessageIDHeader in project arctic-sea by 52North.

the class WsaDecoder method decode.

@Override
public List<WsaHeader> decode(List<SOAPHeaderElement> list) {
    List<WsaHeader> wsaHeaders = Lists.newArrayListWithCapacity(list.size());
    boolean to = false;
    boolean replyTo = false;
    boolean messageId = false;
    boolean action = false;
    for (SOAPHeaderElement soapHeaderElement : list) {
        if (soapHeaderElement.getLocalName().equals(WsaConstants.EN_TO)) {
            wsaHeaders.add(new WsaToHeader(soapHeaderElement.getValue()));
            to = true;
        } else if (soapHeaderElement.getLocalName().equals(WsaConstants.EN_ACTION)) {
            wsaHeaders.add(new WsaActionHeader(soapHeaderElement.getValue()));
            action = true;
        } else if (soapHeaderElement.getLocalName().equals(WsaConstants.EN_REPLY_TO)) {
            Iterator<?> iter = soapHeaderElement.getChildElements();
            while (iter.hasNext()) {
                Node node = (Node) iter.next();
                if (node.getLocalName() != null && node.getLocalName().equals(WsaConstants.EN_ADDRESS)) {
                    wsaHeaders.add(new WsaReplyToHeader(node.getValue()));
                    replyTo = true;
                }
            }
        } else if (soapHeaderElement.getLocalName().equals(WsaConstants.EN_MESSAGE_ID)) {
            wsaHeaders.add(new WsaMessageIDHeader(soapHeaderElement.getValue()));
            messageId = true;
        }
    }
    if ((to || replyTo || messageId) && !action) {
        wsaHeaders.add(new WsaActionHeader(WsaConstants.WSA_FAULT_ACTION));
    }
    return wsaHeaders;
}
Also used : SOAPHeaderElement(javax.xml.soap.SOAPHeaderElement) WsaReplyToHeader(org.n52.shetland.w3c.wsa.WsaReplyToHeader) WsaMessageIDHeader(org.n52.shetland.w3c.wsa.WsaMessageIDHeader) Node(javax.xml.soap.Node) WsaToHeader(org.n52.shetland.w3c.wsa.WsaToHeader) WsaHeader(org.n52.shetland.w3c.wsa.WsaHeader) WsaActionHeader(org.n52.shetland.w3c.wsa.WsaActionHeader)

Aggregations

Node (javax.xml.soap.Node)1 SOAPHeaderElement (javax.xml.soap.SOAPHeaderElement)1 WsaActionHeader (org.n52.shetland.w3c.wsa.WsaActionHeader)1 WsaHeader (org.n52.shetland.w3c.wsa.WsaHeader)1 WsaMessageIDHeader (org.n52.shetland.w3c.wsa.WsaMessageIDHeader)1 WsaReplyToHeader (org.n52.shetland.w3c.wsa.WsaReplyToHeader)1 WsaToHeader (org.n52.shetland.w3c.wsa.WsaToHeader)1