com.sun.xml.internal.ws.api.addressing.AddressingVersion Java Examples

The following examples show how to use com.sun.xml.internal.ws.api.addressing.AddressingVersion. 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: Packet.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void populateAddressingHeaders(WSBinding binding, Packet responsePacket, WSDLPort wsdlPort, SEIModel seiModel) {
    AddressingVersion addressingVersion = binding.getAddressingVersion();

    if (addressingVersion == null) {
        return;
    }

    WsaTubeHelper wsaHelper = addressingVersion.getWsaHelper(wsdlPort, seiModel, binding);
    String action = responsePacket.getMessage().isFault() ?
            wsaHelper.getFaultAction(this, responsePacket) :
            wsaHelper.getOutputAction(this);
    if (action == null) {
        LOGGER.info("WSA headers are not added as value for wsa:Action cannot be resolved for this message");
        return;
    }
    populateAddressingHeaders(responsePacket, addressingVersion, binding.getSOAPVersion(), action, AddressingVersion.isRequired(binding));
}
 
Example #2
Source File: EndpointReferenceUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static Map<QName, String> getAttributes(Node node) {
    Map<QName, String> attribs = null;

    NamedNodeMap nm = node.getAttributes();
    for (int i = 0; i < nm.getLength(); i++) {
        if (attribs == null) {
            attribs = new HashMap<QName, String>();
        }
        Node n = nm.item(i);
        String prefix = fixNull(n.getPrefix());
        String ns = fixNull(n.getNamespaceURI());
        String localName = n.getLocalName();
        if (prefix.equals("xmlns") || prefix.length() == 0 && localName.equals("xmlns")) {
            continue;
        }

        //exclude some attributes
        if (!localName.equals(AddressingVersion.W3C.eprType.portName)) {
            attribs.put(new QName(ns, localName, prefix), n.getNodeValue());
        }
    }
    return attribs;
}
 
Example #3
Source File: WsaTube.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
final boolean isAddressingEngagedOrRequired(Packet packet, WSBinding binding) {
    if (AddressingVersion.isRequired(binding))
        return true;

    if (packet == null)
        return false;

    if (packet.getMessage() == null)
        return false;

    if (packet.getMessage().getHeaders() != null)
        return false;

    String action = AddressingUtils.getAction(
            packet.getMessage().getHeaders(),
            addressingVersion, soapVersion);
    if (action == null)
        return true;

    return true;
}
 
Example #4
Source File: AddressingUtils.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void fillRequestAddressingHeaders(MessageHeaders headers, Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action, boolean mustUnderstand) {
    fillCommonAddressingHeaders(headers, packet, av, sv, action, mustUnderstand);

    // wsa:ReplyTo
    // null or "true" is equivalent to request/response MEP
    if (!oneway) {
        WSEndpointReference epr = av.anonymousEpr;
        if (headers.get(av.replyToTag, false) == null) {
          headers.add(epr.createHeader(av.replyToTag));
        }

        // wsa:FaultTo
        if (headers.get(av.faultToTag, false) == null) {
          headers.add(epr.createHeader(av.faultToTag));
        }

        // wsa:MessageID
        if (packet.getMessage().getHeaders().get(av.messageIDTag, false) == null) {
            if (headers.get(av.messageIDTag, false) == null) {
                Header h = new StringHeader(av.messageIDTag, Message.generateMessageID());
                headers.add(h);
            }
        }
    }
}
 
Example #5
Source File: Packet.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void populateAddressingHeaders(WSBinding binding, Packet responsePacket, WSDLPort wsdlPort, SEIModel seiModel) {
    AddressingVersion addressingVersion = binding.getAddressingVersion();

    if (addressingVersion == null) {
        return;
    }

    WsaTubeHelper wsaHelper = addressingVersion.getWsaHelper(wsdlPort, seiModel, binding);
    String action = responsePacket.getMessage().isFault() ?
            wsaHelper.getFaultAction(this, responsePacket) :
            wsaHelper.getOutputAction(this);
    if (action == null) {
        LOGGER.info("WSA headers are not added as value for wsa:Action cannot be resolved for this message");
        return;
    }
    populateAddressingHeaders(responsePacket, addressingVersion, binding.getSOAPVersion(), action, AddressingVersion.isRequired(binding));
}
 
Example #6
Source File: WsaTube.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
final boolean isAddressingEngagedOrRequired(Packet packet, WSBinding binding) {
    if (AddressingVersion.isRequired(binding))
        return true;

    if (packet == null)
        return false;

    if (packet.getMessage() == null)
        return false;

    if (packet.getMessage().getHeaders() != null)
        return false;

    String action = AddressingUtils.getAction(
            packet.getMessage().getHeaders(),
            addressingVersion, soapVersion);
    if (action == null)
        return true;

    return true;
}
 
Example #7
Source File: WsaTube.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
final boolean isAddressingEngagedOrRequired(Packet packet, WSBinding binding) {
    if (AddressingVersion.isRequired(binding))
        return true;

    if (packet == null)
        return false;

    if (packet.getMessage() == null)
        return false;

    if (packet.getMessage().getHeaders() != null)
        return false;

    String action = AddressingUtils.getAction(
            packet.getMessage().getHeaders(),
            addressingVersion, soapVersion);
    if (action == null)
        return true;

    return true;
}
 
Example #8
Source File: EndpointReferenceUtil.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static Map<QName, String> getAttributes(Node node) {
    Map<QName, String> attribs = null;

    NamedNodeMap nm = node.getAttributes();
    for (int i = 0; i < nm.getLength(); i++) {
        if (attribs == null) {
            attribs = new HashMap<QName, String>();
        }
        Node n = nm.item(i);
        String prefix = fixNull(n.getPrefix());
        String ns = fixNull(n.getNamespaceURI());
        String localName = n.getLocalName();
        if (prefix.equals("xmlns") || prefix.length() == 0 && localName.equals("xmlns")) {
            continue;
        }

        //exclude some attributes
        if (!localName.equals(AddressingVersion.W3C.eprType.portName)) {
            attribs.put(new QName(ns, localName, prefix), n.getNodeValue());
        }
    }
    return attribs;
}
 
Example #9
Source File: Packet.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void populateAddressingHeaders(WSBinding binding, Packet responsePacket, WSDLPort wsdlPort, SEIModel seiModel) {
    AddressingVersion addressingVersion = binding.getAddressingVersion();

    if (addressingVersion == null) {
        return;
    }

    WsaTubeHelper wsaHelper = addressingVersion.getWsaHelper(wsdlPort, seiModel, binding);
    String action = responsePacket.getMessage().isFault() ?
            wsaHelper.getFaultAction(this, responsePacket) :
            wsaHelper.getOutputAction(this);
    if (action == null) {
        LOGGER.info("WSA headers are not added as value for wsa:Action cannot be resolved for this message");
        return;
    }
    populateAddressingHeaders(responsePacket, addressingVersion, binding.getSOAPVersion(), action, AddressingVersion.isRequired(binding));
}
 
Example #10
Source File: W3CAddressingWSDLGeneratorExtension.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void addBindingExtension(TypedXmlWriter binding) {
    if (!enabled)
        return;
    binding._element(AddressingVersion.W3C.wsdlExtensionTag, UsingAddressing.class);
    /*
    Do not generate wsdl:required=true
    if(required) {
        ua.required(true);
    }
    */
}
 
Example #11
Source File: WsaTubeHelper.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
    QName name = e.getProblemHeader();
    QName subsubcode = e.getSubsubcode();
    QName subcode = av.invalidMapTag;
    String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);

    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getInvalidMapDetail(name, fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }

        fault.setFaultString(faultstring);

        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
 
Example #12
Source File: Messages.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a fault {@link Message} that captures the code/subcode/subsubcode
 * defined by WS-Addressing if wsa:Action is not supported.
 *
 * @param unsupportedAction The unsupported Action. Must not be null.
 * @param av The WS-Addressing version of the message. Must not be null.
 * @param sv The SOAP Version of the message. Must not be null.
 *
 * @return
 *      A message representing SOAPFault that contains the WS-Addressing code/subcode/subsubcode.
 */
public static Message create(@NotNull String unsupportedAction, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
    QName subcode = av.actionNotSupportedTag;
    String faultstring = String.format(av.actionNotSupportedText, unsupportedAction);

    Message faultMessage;
    SOAPFault fault;
    try {
        if (sv == SOAPVersion.SOAP_12) {
            fault = SOAPVersion.SOAP_12.getSOAPFactory().createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            Detail detail = fault.addDetail();
            SOAPElement se = detail.addChildElement(av.problemActionTag);
            se = se.addChildElement(av.actionTag);
            se.addTextNode(unsupportedAction);
        } else {
            fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault();
            fault.setFaultCode(subcode);
        }
        fault.setFaultString(faultstring);

        faultMessage = SOAPFaultBuilder.createSOAPFaultMessage(sv, fault);
        if (sv == SOAPVersion.SOAP_11) {
            faultMessage.getHeaders().add(new ProblemActionHeader(unsupportedAction, av));
        }
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }

    return faultMessage;
}
 
Example #13
Source File: W3CAddressingWSDLGeneratorExtension.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void start(WSDLGenExtnContext ctxt) {
    WSBinding binding = ctxt.getBinding();
    TypedXmlWriter root = ctxt.getRoot();
    enabled = binding.isFeatureEnabled(AddressingFeature.class);
    if (!enabled)
        return;
    AddressingFeature ftr = binding.getFeature(AddressingFeature.class);
    required = ftr.isRequired();
    root._namespace(AddressingVersion.W3C.wsdlNsUri, AddressingVersion.W3C.getWsdlPrefix());
}
 
Example #14
Source File: Fiber.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void dumpFiberContext(String desc) {
    if(isTraceEnabled()) {
        String action = null;
        String msgId = null;
        if (packet != null) {
            for (SOAPVersion sv: SOAPVersion.values()) {
                for (AddressingVersion av: AddressingVersion.values()) {
                    action = packet.getMessage() != null ? AddressingUtils.getAction(packet.getMessage().getHeaders(), av, sv) : null;
                    msgId = packet.getMessage() != null ? AddressingUtils.getMessageID(packet.getMessage().getHeaders(), av, sv) : null;
                    if (action != null || msgId != null) {
                       break;
                    }
                }
                if (action != null || msgId != null) {
                    break;
                }
            }
        }
        String actionAndMsgDesc;
        if (action == null && msgId == null) {
            actionAndMsgDesc = "NO ACTION or MSG ID";
        } else {
            actionAndMsgDesc = "'" + action + "' and msgId '" + msgId + "'";
        }

        String tubeDesc;
        if (next != null) {
            tubeDesc = next.toString() + ".processRequest()";
        } else {
            tubeDesc = peekCont() + ".processResponse()";
        }

        LOGGER.log(Level.FINE, "{0} {1} with {2} and ''current'' tube {3} from thread {4} with Packet: {5}", new Object[]{getName(), desc, actionAndMsgDesc, tubeDesc, Thread.currentThread().getName(), packet != null ? packet.toShortString() : null});
    }
}
 
Example #15
Source File: BindingImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public AddressingVersion getAddressingVersion() {
    AddressingVersion addressingVersion;
    if (features.isEnabled(AddressingFeature.class))
        addressingVersion = AddressingVersion.W3C;
    else if (features.isEnabled(MemberSubmissionAddressingFeature.class))
        addressingVersion = AddressingVersion.MEMBER;
    else
        addressingVersion = null;
    return addressingVersion;
}
 
Example #16
Source File: Stub.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final WSEndpointReference getWSEndpointReference() {
    if (binding.getBindingID().equals(HTTPBinding.HTTP_BINDING)) {
        throw new java.lang.UnsupportedOperationException(
                    ClientMessages.UNSUPPORTED_OPERATION("BindingProvider.getEndpointReference(Class<T> class)", "XML/HTTP Binding", "SOAP11 or SOAP12 Binding")
                );
    }

    if (endpointReference != null) {
        return endpointReference;
    }

    String eprAddress = requestContext.getEndpointAddress().toString();
    QName portTypeName = null;
    String wsdlAddress = null;
    List<WSEndpointReference.EPRExtension> wsdlEPRExtensions = new ArrayList<WSEndpointReference.EPRExtension>();
    if (wsdlPort != null) {
        portTypeName = wsdlPort.getBinding().getPortTypeName();
        wsdlAddress = eprAddress + "?wsdl";

        //gather EPRExtensions specified in WSDL.
        try {
            WSEndpointReference wsdlEpr = wsdlPort.getEPR();
            if (wsdlEpr != null) {
                for (WSEndpointReference.EPRExtension extnEl : wsdlEpr.getEPRExtensions()) {
                    wsdlEPRExtensions.add(new WSEPRExtension(
                            XMLStreamBuffer.createNewBufferFromXMLStreamReader(extnEl.readAsXMLStreamReader()), extnEl.getQName()));
                }
            }

        } catch (XMLStreamException ex) {
            throw new WebServiceException(ex);
        }
    }
    AddressingVersion av = AddressingVersion.W3C;
    this.endpointReference = new WSEndpointReference(
            av, eprAddress, getServiceName(), getPortName(), portTypeName, null, wsdlAddress, null, wsdlEPRExtensions, null);

    return this.endpointReference;
}
 
Example #17
Source File: ServerTubeAssemblerContext.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates WS-Addressing pipe
 */
public Tube createWsaTube(Tube next) {
    if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding)) {
        if(AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) {
            return new MemberSubmissionWsaServerTube(endpoint, wsdlModel, binding, next);
        } else {
            return new W3CWsaServerTube(endpoint, wsdlModel, binding, next);
        }
    } else
        return next;
}
 
Example #18
Source File: AbstractHeaderImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Default implementation that copies the infoset. Not terribly efficient.
 */
public WSEndpointReference readAsEPR(AddressingVersion expected) throws XMLStreamException {
    XMLStreamReader xsr = readHeader();
    WSEndpointReference epr = new WSEndpointReference(xsr, expected);
    XMLStreamReaderFactory.recycle(xsr);
    return epr;
}
 
Example #19
Source File: W3CAddressingWSDLParserExtension.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private boolean addressibleElement(XMLStreamReader reader, WSDLFeaturedObject binding) {
    QName ua = reader.getName();
    if (ua.equals(AddressingVersion.W3C.wsdlExtensionTag)) {
        String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
        binding.addFeature(new AddressingFeature(true, Boolean.parseBoolean(required)));
        XMLStreamReaderUtil.skipElement(reader);
        return true;        // UsingAddressing is consumed
    }

    return false;
}
 
Example #20
Source File: ClientTubeAssemblerContext.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Tube} that invokes protocol and logical handlers.
 */
public Tube createWsaTube(Tube next) {
    if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding) && wsdlModel!=null)
        if(AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) {
            return new MemberSubmissionWsaClientTube(wsdlModel, binding, next);
        } else {
            return new W3CWsaClientTube(wsdlModel, binding, next);
        }
    else
        return next;
}
 
Example #21
Source File: MemberSubmissionAddressingWSDLParserExtension.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private boolean addressibleElement(XMLStreamReader reader, WSDLFeaturedObject binding) {
    QName ua = reader.getName();
    if (ua.equals(AddressingVersion.MEMBER.wsdlExtensionTag)) {
        String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
        binding.addFeature(new MemberSubmissionAddressingFeature(Boolean.parseBoolean(required)));
        XMLStreamReaderUtil.skipElement(reader);
        return true;        // UsingAddressing is consumed
    }

    return false;
}
 
Example #22
Source File: ClientTubeAssemblerContext.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Tube} that invokes protocol and logical handlers.
 */
public Tube createWsaTube(Tube next) {
    if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding) && wsdlModel!=null)
        if(AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) {
            return new MemberSubmissionWsaClientTube(wsdlModel, binding, next);
        } else {
            return new W3CWsaClientTube(wsdlModel, binding, next);
        }
    else
        return next;
}
 
Example #23
Source File: BindingImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public AddressingVersion getAddressingVersion() {
    AddressingVersion addressingVersion;
    if (features.isEnabled(AddressingFeature.class))
        addressingVersion = AddressingVersion.W3C;
    else if (features.isEnabled(MemberSubmissionAddressingFeature.class))
        addressingVersion = AddressingVersion.MEMBER;
    else
        addressingVersion = null;
    return addressingVersion;
}
 
Example #24
Source File: Message.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retuns a unique id for the message.
 * <p><p>
 * @see {@link #getID(com.sun.xml.internal.ws.api.WSBinding)} for detailed description.
 * @param av WS-Addressing version
 * @param sv SOAP version
 * @return unique id for the message
 * @deprecated
 */
public @NotNull String getID(AddressingVersion av, SOAPVersion sv) {
    String uuid = null;
    if (av != null) {
        uuid = AddressingUtils.getMessageID(getHeaders(), av, sv);
    }
    if (uuid == null) {
        uuid = generateMessageID();
        getHeaders().add(new StringHeader(av.messageIDTag, uuid));
    }
    return uuid;
}
 
Example #25
Source File: WsaTubeHelper.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
    QName name = e.getProblemHeader();
    QName subsubcode = e.getSubsubcode();
    QName subcode = av.invalidMapTag;
    String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);

    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getInvalidMapDetail(name, fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }

        fault.setFaultString(faultstring);

        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
 
Example #26
Source File: Messages.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a fault {@link Message} that captures the code/subcode/subsubcode
 * defined by WS-Addressing if wsa:Action is not supported.
 *
 * @param unsupportedAction The unsupported Action. Must not be null.
 * @param av The WS-Addressing version of the message. Must not be null.
 * @param sv The SOAP Version of the message. Must not be null.
 *
 * @return
 *      A message representing SOAPFault that contains the WS-Addressing code/subcode/subsubcode.
 */
public static Message create(@NotNull String unsupportedAction, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
    QName subcode = av.actionNotSupportedTag;
    String faultstring = String.format(av.actionNotSupportedText, unsupportedAction);

    Message faultMessage;
    SOAPFault fault;
    try {
        if (sv == SOAPVersion.SOAP_12) {
            fault = SOAPVersion.SOAP_12.getSOAPFactory().createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            Detail detail = fault.addDetail();
            SOAPElement se = detail.addChildElement(av.problemActionTag);
            se = se.addChildElement(av.actionTag);
            se.addTextNode(unsupportedAction);
        } else {
            fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault();
            fault.setFaultCode(subcode);
        }
        fault.setFaultString(faultstring);

        faultMessage = SOAPFaultBuilder.createSOAPFaultMessage(sv, fault);
        if (sv == SOAPVersion.SOAP_11) {
            faultMessage.getHeaders().add(new ProblemActionHeader(unsupportedAction, av));
        }
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }

    return faultMessage;
}
 
Example #27
Source File: WsaTube.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void addKnownHeadersToBinding(WSBinding binding) {
    for (AddressingVersion addrVersion: AddressingVersion.values()) {
      binding.addKnownHeader(addrVersion.actionTag);
      binding.addKnownHeader(addrVersion.faultDetailTag);
      binding.addKnownHeader(addrVersion.faultToTag);
      binding.addKnownHeader(addrVersion.fromTag);
      binding.addKnownHeader(addrVersion.messageIDTag);
      binding.addKnownHeader(addrVersion.relatesToTag);
      binding.addKnownHeader(addrVersion.replyToTag);
      binding.addKnownHeader(addrVersion.toTag);
    }
}
 
Example #28
Source File: Stub.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final WSEndpointReference getWSEndpointReference() {
    if (binding.getBindingID().equals(HTTPBinding.HTTP_BINDING)) {
        throw new java.lang.UnsupportedOperationException(
                    ClientMessages.UNSUPPORTED_OPERATION("BindingProvider.getEndpointReference(Class<T> class)", "XML/HTTP Binding", "SOAP11 or SOAP12 Binding")
                );
    }

    if (endpointReference != null) {
        return endpointReference;
    }

    String eprAddress = requestContext.getEndpointAddress().toString();
    QName portTypeName = null;
    String wsdlAddress = null;
    List<WSEndpointReference.EPRExtension> wsdlEPRExtensions = new ArrayList<WSEndpointReference.EPRExtension>();
    if (wsdlPort != null) {
        portTypeName = wsdlPort.getBinding().getPortTypeName();
        wsdlAddress = eprAddress + "?wsdl";

        //gather EPRExtensions specified in WSDL.
        try {
            WSEndpointReference wsdlEpr = wsdlPort.getEPR();
            if (wsdlEpr != null) {
                for (WSEndpointReference.EPRExtension extnEl : wsdlEpr.getEPRExtensions()) {
                    wsdlEPRExtensions.add(new WSEPRExtension(
                            XMLStreamBuffer.createNewBufferFromXMLStreamReader(extnEl.readAsXMLStreamReader()), extnEl.getQName()));
                }
            }

        } catch (XMLStreamException ex) {
            throw new WebServiceException(ex);
        }
    }
    AddressingVersion av = AddressingVersion.W3C;
    this.endpointReference = new WSEndpointReference(
            av, eprAddress, getServiceName(), getPortName(), portTypeName, null, wsdlAddress, null, wsdlEPRExtensions, null);

    return this.endpointReference;
}
 
Example #29
Source File: Messages.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a fault {@link Message} that captures the code/subcode/subsubcode
 * defined by WS-Addressing if wsa:Action is not supported.
 *
 * @param unsupportedAction The unsupported Action. Must not be null.
 * @param av The WS-Addressing version of the message. Must not be null.
 * @param sv The SOAP Version of the message. Must not be null.
 *
 * @return
 *      A message representing SOAPFault that contains the WS-Addressing code/subcode/subsubcode.
 */
public static Message create(@NotNull String unsupportedAction, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
    QName subcode = av.actionNotSupportedTag;
    String faultstring = String.format(av.actionNotSupportedText, unsupportedAction);

    Message faultMessage;
    SOAPFault fault;
    try {
        if (sv == SOAPVersion.SOAP_12) {
            fault = SOAPVersion.SOAP_12.getSOAPFactory().createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            Detail detail = fault.addDetail();
            SOAPElement se = detail.addChildElement(av.problemActionTag);
            se = se.addChildElement(av.actionTag);
            se.addTextNode(unsupportedAction);
        } else {
            fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault();
            fault.setFaultCode(subcode);
        }
        fault.setFaultString(faultstring);

        faultMessage = SOAPFaultBuilder.createSOAPFaultMessage(sv, fault);
        if (sv == SOAPVersion.SOAP_11) {
            faultMessage.getHeaders().add(new ProblemActionHeader(unsupportedAction, av));
        }
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }

    return faultMessage;
}
 
Example #30
Source File: ServerTubeAssemblerContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates WS-Addressing pipe
 */
public Tube createWsaTube(Tube next) {
    if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding)) {
        if(AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) {
            return new MemberSubmissionWsaServerTube(endpoint, wsdlModel, binding, next);
        } else {
            return new W3CWsaServerTube(endpoint, wsdlModel, binding, next);
        }
    } else
        return next;
}