Java Code Examples for com.sun.xml.internal.ws.fault.SOAPFaultBuilder#createSOAPFaultMessage()

The following examples show how to use com.sun.xml.internal.ws.fault.SOAPFaultBuilder#createSOAPFaultMessage() . 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: MUTube.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This should be used only in ServerMUPipe
 *
 * @param notUnderstoodHeaders
 * @return Message representing a SOAPFault
 *         In SOAP 1.1, notUnderstoodHeaders are added in the fault Detail
 *         in SOAP 1.2, notUnderstoodHeaders are added as the SOAP Headers
 */

final Message createMUSOAPFaultMessage(Set<QName> notUnderstoodHeaders) {
    try {
        String faultString = MUST_UNDERSTAND_FAULT_MESSAGE_STRING;
        if (soapVersion == SOAP_11) {
            faultString = "MustUnderstand headers:" + notUnderstoodHeaders + " are not understood";
        }
        Message  muFaultMessage = SOAPFaultBuilder.createSOAPFaultMessage(
                soapVersion,faultString,soapVersion.faultCodeMustUnderstand);

        if (soapVersion == SOAP_12) {
            addHeader(muFaultMessage, notUnderstoodHeaders);
        }
        return muFaultMessage;
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example 2
Source File: OperationDispatcher.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public @NotNull WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
    WSDLOperationMapping opName;
    for(WSDLOperationFinder finder: opFinders) {
        opName = finder.getWSDLOperationMapping(request);
        if(opName != null)
            return opName;
    }
    //No way to dispatch this request
    String err = MessageFormat.format("Request=[SOAPAction={0},Payload='{'{1}'}'{2}]",
            request.soapAction, request.getMessage().getPayloadNamespaceURI(),
            request.getMessage().getPayloadLocalPart());
    String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(err);
    Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage(
            binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient);
    throw new DispatchException(faultMsg);
}
 
Example 3
Source File: OperationDispatcher.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public @NotNull WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
    WSDLOperationMapping opName;
    for(WSDLOperationFinder finder: opFinders) {
        opName = finder.getWSDLOperationMapping(request);
        if(opName != null)
            return opName;
    }
    //No way to dispatch this request
    String err = MessageFormat.format("Request=[SOAPAction={0},Payload='{'{1}'}'{2}]",
            request.soapAction, request.getMessage().getPayloadNamespaceURI(),
            request.getMessage().getPayloadLocalPart());
    String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(err);
    Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage(
            binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient);
    throw new DispatchException(faultMsg);
}
 
Example 4
Source File: ServerSchemaValidationTube.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public NextAction processRequest(Packet request) {
    if (isNoValidation() || !feature.isInbound() || !request.getMessage().hasPayload() || request.getMessage().isFault()) {
        return super.processRequest(request);
    }
    try {
        doProcess(request);
    } catch(SAXException se) {
        LOGGER.log(Level.WARNING, "Client Request doesn't pass Service's Schema Validation", se);
        // Client request is invalid. So sending specific fault code
        // Also converting this to fault message so that handlers may get
        // to see the message.
        SOAPVersion soapVersion = binding.getSOAPVersion();
        Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage(
                soapVersion, null, se, soapVersion.faultCodeClient);
        return doReturnWith(request.createServerResponse(faultMsg,
                wsdlPort, seiModel, binding));
    }
    return super.processRequest(request);
}
 
Example 5
Source File: VersionMismatchException.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Message getFaultMessage() {
    QName faultCode = (soapVersion == SOAPVersion.SOAP_11)
        ? SOAPConstants.FAULT_CODE_VERSION_MISMATCH
        : SOAP12Constants.FAULT_CODE_VERSION_MISMATCH;
    return SOAPFaultBuilder.createSOAPFaultMessage(
            soapVersion, getLocalizedMessage(), faultCode);
}
 
Example 6
Source File: WSEndpointImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public @NotNull
PipeHead createPipeHead() {
    return new PipeHead() {
        private final Tube tube = TubeCloner.clone(masterTubeline);

        public @NotNull
        Packet process(Packet request, WebServiceContextDelegate wscd,
                TransportBackChannel tbc) {
            Container old = ContainerResolver.getDefault().enterContainer(container);
            try {
                request.webServiceContextDelegate = wscd;
                request.transportBackChannel = tbc;
                request.endpoint = WSEndpointImpl.this;
                request.addSatellite(wsdlProperties);

                Fiber fiber = engine.createFiber();
                Packet response;
                try {
                    response = fiber.runSync(tube, request);
                } catch (RuntimeException re) {
                    // Catch all runtime exceptions so that transport
                    // doesn't
                    // have to worry about converting to wire message
                    // TODO XML/HTTP binding
                    Message faultMsg = SOAPFaultBuilder
                            .createSOAPFaultMessage(soapVersion, null, re);
                    response = request.createServerResponse(faultMsg,
                            request.endpoint.getPort(), null,
                            request.endpoint.getBinding());
                }
                return response;
            } finally {
                ContainerResolver.getDefault().exitContainer(old);
            }
        }
    };
}
 
Example 7
Source File: WSEndpointImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public @NotNull
PipeHead createPipeHead() {
    return new PipeHead() {
        private final Tube tube = TubeCloner.clone(masterTubeline);

        public @NotNull
        Packet process(Packet request, WebServiceContextDelegate wscd,
                TransportBackChannel tbc) {
            Container old = ContainerResolver.getDefault().enterContainer(container);
            try {
                request.webServiceContextDelegate = wscd;
                request.transportBackChannel = tbc;
                request.endpoint = WSEndpointImpl.this;
                request.addSatellite(wsdlProperties);

                Fiber fiber = engine.createFiber();
                Packet response;
                try {
                    response = fiber.runSync(tube, request);
                } catch (RuntimeException re) {
                    // Catch all runtime exceptions so that transport
                    // doesn't
                    // have to worry about converting to wire message
                    // TODO XML/HTTP binding
                    Message faultMsg = SOAPFaultBuilder
                            .createSOAPFaultMessage(soapVersion, null, re);
                    response = request.createServerResponse(faultMsg,
                            request.endpoint.getPort(), null,
                            request.endpoint.getBinding());
                }
                return response;
            } finally {
                ContainerResolver.getDefault().exitContainer(old);
            }
        }
    };
}
 
Example 8
Source File: Messages.java    From openjdk-jdk9 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 9
Source File: SOAPProviderArgumentBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected Message getResponseMessage(Exception e) {
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
 
Example 10
Source File: ProviderArgumentsBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Message getResponseMessage(Exception e) {
    // Will be called by AsyncProviderCallbackImpl.sendError
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
 
Example 11
Source File: SOAPProviderArgumentBuilder.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected Message getResponseMessage(Exception e) {
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
 
Example 12
Source File: ProviderArgumentsBuilder.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Message getResponseMessage(Exception e) {
    // Will be called by AsyncProviderCallbackImpl.sendError
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
 
Example 13
Source File: MessageCreationException.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public Message getFaultMessage() {
    QName faultCode = soapVersion.faultCodeClient;
    return SOAPFaultBuilder.createSOAPFaultMessage(
            soapVersion, getLocalizedMessage(), faultCode);
}
 
Example 14
Source File: SOAPProviderArgumentBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected Message getResponseMessage(Exception e) {
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
 
Example 15
Source File: SOAPProviderArgumentBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected Message getResponseMessage(Exception e) {
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
 
Example 16
Source File: SOAPProviderArgumentBuilder.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected Message getResponseMessage(Exception e) {
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
 
Example 17
Source File: SOAPProviderArgumentBuilder.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected Message getResponseMessage(Exception e) {
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
 
Example 18
Source File: Messages.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a {@link Message} that represents an exception as a fault. The
 * created message reflects if t or t.getCause() is SOAPFaultException.
 *
 * creates a fault message with default faultCode env:Server if t or t.getCause()
 * is not SOAPFaultException. Otherwise, it use SOAPFaultException's faultCode
 *
 * @return
 *      Always non-null. A message that wraps this {@link Throwable}.
 *
 */
public static Message create(Throwable t, SOAPVersion soapVersion) {
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, t);
}
 
Example 19
Source File: Messages.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a {@link Message} that represents an exception as a fault. The
 * created message reflects if t or t.getCause() is SOAPFaultException.
 *
 * creates a fault message with default faultCode env:Server if t or t.getCause()
 * is not SOAPFaultException. Otherwise, it use SOAPFaultException's faultCode
 *
 * @return
 *      Always non-null. A message that wraps this {@link Throwable}.
 *
 */
public static Message create(Throwable t, SOAPVersion soapVersion) {
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, t);
}
 
Example 20
Source File: Messages.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a {@link Message} that represents an exception as a fault. The
 * created message reflects if t or t.getCause() is SOAPFaultException.
 *
 * creates a fault message with default faultCode env:Server if t or t.getCause()
 * is not SOAPFaultException. Otherwise, it use SOAPFaultException's faultCode
 *
 * @return
 *      Always non-null. A message that wraps this {@link Throwable}.
 *
 */
public static Message create(Throwable t, SOAPVersion soapVersion) {
    return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, t);
}