Search in sources :

Example 81 with WebServiceException

use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.

the class WSEndpointReference method writeWsdliLocation.

/**
 * @param writer the writer should be at the start of element.
 * @param service Namespace URI of servcie is used as targetNamespace of wsdl if wsdlTargetNamespace is not null
 * @param wsdlAddress  wsdl location
 * @param wsdlTargetNamespace  targetnamespace of wsdl to be put in wsdliLocation
 */
private static void writeWsdliLocation(StreamWriterBufferCreator writer, QName service, String wsdlAddress, String wsdlTargetNamespace) throws XMLStreamException {
    String wsdliLocation = "";
    if (wsdlTargetNamespace != null) {
        wsdliLocation = wsdlTargetNamespace + " ";
    } else if (service != null) {
        wsdliLocation = service.getNamespaceURI() + " ";
    } else {
        throw new WebServiceException("WSDL target Namespace cannot be resolved");
    }
    wsdliLocation += wsdlAddress;
    writer.writeNamespace(W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_PREFIX, W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_NAMESPACE);
    writer.writeAttribute(W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_PREFIX, W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_NAMESPACE, W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_LOCALNAME, wsdliLocation);
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException)

Example 82 with WebServiceException

use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.

the class ManagementAssertion method getAssertion.

/**
 * Return ManagementAssertion if one can be found in the policy map under
 * the given service and port name.
 *
 * @param <T> The implementation class of the assertion.
 * @param name The fully qualified name of the server or client assertion.
 * @param policyMap The policy map. May be null.
 * @param serviceName The WSDL service name. May not be null.
 * @param portName The WSDL port name. May not be null.
 * @param type The implementation class of the assertion.
 * @return An instance of ManagementAssertion or null.
 * @throws WebServiceException If computing the effective policy of the endpoint scope failed.
 */
protected static <T extends ManagementAssertion> T getAssertion(final QName name, final PolicyMap policyMap, QName serviceName, QName portName, Class<T> type) throws WebServiceException {
    try {
        PolicyAssertion assertion = null;
        if (policyMap != null) {
            final PolicyMapKey key = PolicyMap.createWsdlEndpointScopeKey(serviceName, portName);
            final Policy policy = policyMap.getEndpointEffectivePolicy(key);
            if (policy != null) {
                final Iterator<AssertionSet> assertionSets = policy.iterator();
                if (assertionSets.hasNext()) {
                    final AssertionSet assertionSet = assertionSets.next();
                    final Iterator<PolicyAssertion> assertions = assertionSet.get(name).iterator();
                    if (assertions.hasNext()) {
                        assertion = assertions.next();
                    }
                }
            }
        }
        return assertion == null ? null : assertion.getImplementation(type);
    } catch (PolicyException ex) {
        throw LOGGER.logSevereException(new WebServiceException(ManagementMessages.WSM_1001_FAILED_ASSERTION(name), ex));
    }
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) WebServiceException(jakarta.xml.ws.WebServiceException) PolicyMapKey(com.sun.xml.ws.policy.PolicyMapKey) PolicyException(com.sun.xml.ws.policy.PolicyException) AssertionSet(com.sun.xml.ws.policy.AssertionSet)

Example 83 with WebServiceException

use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.

the class AddressingUtils method getFaultTo.

public static WSEndpointReference getFaultTo(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
    if (av == null) {
        throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
    }
    Header h = getFirstHeader(headers, av.faultToTag, true, sv);
    WSEndpointReference faultTo = null;
    if (h != null) {
        try {
            faultTo = h.readAsEPR(av);
        } catch (XMLStreamException e) {
            throw new WebServiceException(AddressingMessages.FAULT_TO_CANNOT_PARSE(), e);
        }
    }
    return faultTo;
}
Also used : StringHeader(com.sun.xml.ws.message.StringHeader) RelatesToHeader(com.sun.xml.ws.message.RelatesToHeader) XMLStreamException(javax.xml.stream.XMLStreamException) WebServiceException(jakarta.xml.ws.WebServiceException) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference)

Example 84 with WebServiceException

use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.

the class AddressingUtils method getReplyTo.

public static WSEndpointReference getReplyTo(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
    if (av == null) {
        throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
    }
    Header h = getFirstHeader(headers, av.replyToTag, true, sv);
    WSEndpointReference replyTo;
    if (h != null) {
        try {
            replyTo = h.readAsEPR(av);
        } catch (XMLStreamException e) {
            throw new WebServiceException(AddressingMessages.REPLY_TO_CANNOT_PARSE(), e);
        }
    } else {
        replyTo = av.anonymousEpr;
    }
    return replyTo;
}
Also used : StringHeader(com.sun.xml.ws.message.StringHeader) RelatesToHeader(com.sun.xml.ws.message.RelatesToHeader) XMLStreamException(javax.xml.stream.XMLStreamException) WebServiceException(jakarta.xml.ws.WebServiceException) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference)

Example 85 with WebServiceException

use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.

the class BindingID method customize.

/**
 * Parses parameter portion and returns appropriately populated {@link SOAPHTTPImpl}
 */
private static SOAPHTTPImpl customize(String lexical, SOAPHTTPImpl base) {
    if (lexical.equals(base.toString()))
        return base;
    // otherwise we must have query parameter
    // we assume the spec won't define any tricky parameters that require
    // complicated handling (such as %HH or non-ASCII char), so this parser
    // is quite simple-minded.
    SOAPHTTPImpl r = new SOAPHTTPImpl(base.getSOAPVersion(), lexical, base.canGenerateWSDL());
    // With X_SOAP12_HTTP, base != lexical and lexical does n't have any query string
    if (lexical.indexOf('?') == -1) {
        return r;
    }
    String query = URLDecoder.decode(lexical.substring(lexical.indexOf('?') + 1), StandardCharsets.UTF_8);
    for (String token : query.split("&")) {
        int idx = token.indexOf('=');
        if (idx < 0)
            throw new WebServiceException("Malformed binding ID (no '=' in " + token + ")");
        r.parameters.put(token.substring(0, idx), token.substring(idx + 1));
    }
    return r;
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException)

Aggregations

WebServiceException (jakarta.xml.ws.WebServiceException)386 QName (javax.xml.namespace.QName)49 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)36 SOAPException (jakarta.xml.soap.SOAPException)33 JAXBException (jakarta.xml.bind.JAXBException)30 Node (org.w3c.dom.Node)28 JAXBContext (jakarta.xml.bind.JAXBContext)27 IOException (java.io.IOException)26 SOAPMessage (jakarta.xml.soap.SOAPMessage)25 XMLStreamException (javax.xml.stream.XMLStreamException)25 Source (javax.xml.transform.Source)23 ProtocolException (jakarta.xml.ws.ProtocolException)20 Dispatch (jakarta.xml.ws.Dispatch)19 MalformedURLException (java.net.MalformedURLException)19 MessageContext (jakarta.xml.ws.handler.MessageContext)17 Map (java.util.Map)17 URL (java.net.URL)16 StreamSource (javax.xml.transform.stream.StreamSource)16 HandlerTracker (fromwsdl.handler.common.HandlerTracker)14 HandlerTracker (handler.handler_processing.common.HandlerTracker)14