com.sun.xml.internal.ws.fault.SOAPFaultBuilder Java Examples

The following examples show how to use com.sun.xml.internal.ws.fault.SOAPFaultBuilder. 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: ServerSchemaValidationTube.java    From openjdk-jdk8u-backup 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 #2
Source File: WSEndpointImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Packet createServiceResponseForException(final ThrowableContainerPropertySet tc,
                                                final Packet      responsePacket,
                                                final SOAPVersion soapVersion,
                                                final WSDLPort    wsdlPort,
                                                final SEIModel    seiModel,
                                                final WSBinding   binding)
{
    // This will happen in addressing if it is enabled.
    if (tc.isFaultCreated()) return responsePacket;

    final Message faultMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, tc.getThrowable());
    final Packet result = responsePacket.createServerResponse(faultMessage, wsdlPort, seiModel, binding);
    // Pass info to upper layers
    tc.setFaultMessage(faultMessage);
    tc.setResponsePacket(responsePacket);
    tc.setFaultCreated(true);
    return result;
}
 
Example #3
Source File: WSEndpointImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Packet createServiceResponseForException(final ThrowableContainerPropertySet tc,
                                                final Packet      responsePacket,
                                                final SOAPVersion soapVersion,
                                                final WSDLPort    wsdlPort,
                                                final SEIModel    seiModel,
                                                final WSBinding   binding)
{
    // This will happen in addressing if it is enabled.
    if (tc.isFaultCreated()) return responsePacket;

    final Message faultMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, tc.getThrowable());
    final Packet result = responsePacket.createServerResponse(faultMessage, wsdlPort, seiModel, binding);
    // Pass info to upper layers
    tc.setFaultMessage(faultMessage);
    tc.setResponsePacket(responsePacket);
    tc.setFaultCreated(true);
    return result;
}
 
Example #4
Source File: MUTube.java    From hottub 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 #5
Source File: MUTube.java    From openjdk-jdk8u-backup 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 #6
Source File: PayloadQNameBasedOperationFinder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
     *
     * @return not null if it finds a unique handler for the request
     *         null if it cannot idenitify a unique wsdl operation from the Payload QName.
     *
     * @throws DispatchException if the payload itself is incorrect, this happens when the payload is not accepted by
     *          any operation in the port.
     */
//  public QName getWSDLOperationQName(Packet request) throws DispatchException{

    public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
        Message message = request.getMessage();
        String localPart = message.getPayloadLocalPart();
        String nsUri;
        if (localPart == null) {
            localPart = EMPTY_PAYLOAD_LOCAL;
            nsUri = EMPTY_PAYLOAD_NSURI;
        } else {
            nsUri = message.getPayloadNamespaceURI();
            if(nsUri == null)
                nsUri = EMPTY_PAYLOAD_NSURI;
        }
        WSDLOperationMapping op = methodHandlers.get(nsUri, localPart);

        // Check if payload itself is correct. Usually it is, so let us check last
        if (op == null && !unique.containsKey(nsUri,localPart)) {
            String dispatchKey = "{" + nsUri + "}" + localPart;
            String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(dispatchKey);
            throw new DispatchException(SOAPFaultBuilder.createSOAPFaultMessage(
                 binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient));
        }
        return op;
    }
 
Example #7
Source File: ServerSchemaValidationTube.java    From openjdk-jdk8u 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 #8
Source File: ServerSchemaValidationTube.java    From openjdk-jdk9 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 #9
Source File: ServerSchemaValidationTube.java    From TencentKona-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 #10
Source File: OperationDispatcher.java    From TencentKona-8 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 #11
Source File: PayloadQNameBasedOperationFinder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
     *
     * @return not null if it finds a unique handler for the request
     *         null if it cannot idenitify a unique wsdl operation from the Payload QName.
     *
     * @throws DispatchException if the payload itself is incorrect, this happens when the payload is not accepted by
     *          any operation in the port.
     */
//  public QName getWSDLOperationQName(Packet request) throws DispatchException{

    public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
        Message message = request.getMessage();
        String localPart = message.getPayloadLocalPart();
        String nsUri;
        if (localPart == null) {
            localPart = EMPTY_PAYLOAD_LOCAL;
            nsUri = EMPTY_PAYLOAD_NSURI;
        } else {
            nsUri = message.getPayloadNamespaceURI();
            if(nsUri == null)
                nsUri = EMPTY_PAYLOAD_NSURI;
        }
        WSDLOperationMapping op = methodHandlers.get(nsUri, localPart);

        // Check if payload itself is correct. Usually it is, so let us check last
        if (op == null && !unique.containsKey(nsUri,localPart)) {
            String dispatchKey = "{" + nsUri + "}" + localPart;
            String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(dispatchKey);
            throw new DispatchException(SOAPFaultBuilder.createSOAPFaultMessage(
                 binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient));
        }
        return op;
    }
 
Example #12
Source File: MUTube.java    From jdk8u60 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 #13
Source File: WSEndpointImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Packet createServiceResponseForException(final ThrowableContainerPropertySet tc,
                                                final Packet      responsePacket,
                                                final SOAPVersion soapVersion,
                                                final WSDLPort    wsdlPort,
                                                final SEIModel    seiModel,
                                                final WSBinding   binding)
{
    // This will happen in addressing if it is enabled.
    if (tc.isFaultCreated()) return responsePacket;

    final Message faultMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, tc.getThrowable());
    final Packet result = responsePacket.createServerResponse(faultMessage, wsdlPort, seiModel, binding);
    // Pass info to upper layers
    tc.setFaultMessage(faultMessage);
    tc.setResponsePacket(responsePacket);
    tc.setFaultCreated(true);
    return result;
}
 
Example #14
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 #15
Source File: PayloadQNameBasedOperationFinder.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
     *
     * @return not null if it finds a unique handler for the request
     *         null if it cannot idenitify a unique wsdl operation from the Payload QName.
     *
     * @throws DispatchException if the payload itself is incorrect, this happens when the payload is not accepted by
     *          any operation in the port.
     */
//  public QName getWSDLOperationQName(Packet request) throws DispatchException{

    public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
        Message message = request.getMessage();
        String localPart = message.getPayloadLocalPart();
        String nsUri;
        if (localPart == null) {
            localPart = EMPTY_PAYLOAD_LOCAL;
            nsUri = EMPTY_PAYLOAD_NSURI;
        } else {
            nsUri = message.getPayloadNamespaceURI();
            if(nsUri == null)
                nsUri = EMPTY_PAYLOAD_NSURI;
        }
        WSDLOperationMapping op = methodHandlers.get(nsUri, localPart);

        // Check if payload itself is correct. Usually it is, so let us check last
        if (op == null && !unique.containsKey(nsUri,localPart)) {
            String dispatchKey = "{" + nsUri + "}" + localPart;
            String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(dispatchKey);
            throw new DispatchException(SOAPFaultBuilder.createSOAPFaultMessage(
                 binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient));
        }
        return op;
    }
 
Example #16
Source File: PayloadQNameBasedOperationFinder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
     *
     * @return not null if it finds a unique handler for the request
     *         null if it cannot idenitify a unique wsdl operation from the Payload QName.
     *
     * @throws DispatchException if the payload itself is incorrect, this happens when the payload is not accepted by
     *          any operation in the port.
     */
//  public QName getWSDLOperationQName(Packet request) throws DispatchException{

    public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
        Message message = request.getMessage();
        String localPart = message.getPayloadLocalPart();
        String nsUri;
        if (localPart == null) {
            localPart = EMPTY_PAYLOAD_LOCAL;
            nsUri = EMPTY_PAYLOAD_NSURI;
        } else {
            nsUri = message.getPayloadNamespaceURI();
            if(nsUri == null)
                nsUri = EMPTY_PAYLOAD_NSURI;
        }
        WSDLOperationMapping op = methodHandlers.get(nsUri, localPart);

        // Check if payload itself is correct. Usually it is, so let us check last
        if (op == null && !unique.containsKey(nsUri,localPart)) {
            String dispatchKey = "{" + nsUri + "}" + localPart;
            String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(dispatchKey);
            throw new DispatchException(SOAPFaultBuilder.createSOAPFaultMessage(
                 binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient));
        }
        return op;
    }
 
Example #17
Source File: PayloadQNameBasedOperationFinder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
     *
     * @return not null if it finds a unique handler for the request
     *         null if it cannot idenitify a unique wsdl operation from the Payload QName.
     *
     * @throws DispatchException if the payload itself is incorrect, this happens when the payload is not accepted by
     *          any operation in the port.
     */
//  public QName getWSDLOperationQName(Packet request) throws DispatchException{

    public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
        Message message = request.getMessage();
        String localPart = message.getPayloadLocalPart();
        String nsUri;
        if (localPart == null) {
            localPart = EMPTY_PAYLOAD_LOCAL;
            nsUri = EMPTY_PAYLOAD_NSURI;
        } else {
            nsUri = message.getPayloadNamespaceURI();
            if(nsUri == null)
                nsUri = EMPTY_PAYLOAD_NSURI;
        }
        WSDLOperationMapping op = methodHandlers.get(nsUri, localPart);

        // Check if payload itself is correct. Usually it is, so let us check last
        if (op == null && !unique.containsKey(nsUri,localPart)) {
            String dispatchKey = "{" + nsUri + "}" + localPart;
            String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(dispatchKey);
            throw new DispatchException(SOAPFaultBuilder.createSOAPFaultMessage(
                 binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient));
        }
        return op;
    }
 
Example #18
Source File: ServerSchemaValidationTube.java    From jdk8u60 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 #19
Source File: OperationDispatcher.java    From openjdk-jdk8u-backup 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 #20
Source File: WSEndpointImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Packet createServiceResponseForException(final ThrowableContainerPropertySet tc,
                                                final Packet      responsePacket,
                                                final SOAPVersion soapVersion,
                                                final WSDLPort    wsdlPort,
                                                final SEIModel    seiModel,
                                                final WSBinding   binding)
{
    // This will happen in addressing if it is enabled.
    if (tc.isFaultCreated()) return responsePacket;

    final Message faultMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, tc.getThrowable());
    final Packet result = responsePacket.createServerResponse(faultMessage, wsdlPort, seiModel, binding);
    // Pass info to upper layers
    tc.setFaultMessage(faultMessage);
    tc.setResponsePacket(responsePacket);
    tc.setFaultCreated(true);
    return result;
}
 
Example #21
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 #22
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 #23
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 #24
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 #25
Source File: TieHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Message createResponse(JavaCallInfo call) {
        Message responseMessage;
        if (call.getException() == null) {
            responseMessage = isOneWay ? null : createResponseMessage(call.getParameters(), call.getReturnValue());
        } else {
            Throwable e = call.getException();
            Throwable serviceException = getServiceException(e);
            if (e instanceof InvocationTargetException || serviceException != null) {
//              Throwable cause = e.getCause();
              //if (!(cause instanceof RuntimeException) && cause instanceof Exception) {
                if (serviceException != null) {
                    // Service specific exception
                    LOGGER.log(Level.FINE, serviceException.getMessage(), serviceException);
                    responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion,
                            javaMethodModel.getCheckedException(serviceException.getClass()), serviceException);
                } else {
                    Throwable cause = e.getCause();
                    if (cause instanceof ProtocolException) {
                        // Application code may be throwing it intentionally
                        LOGGER.log(Level.FINE, cause.getMessage(), cause);
                    } else {
                        // Probably some bug in application code
                        LOGGER.log(Level.SEVERE, cause.getMessage(), cause);
                    }
                    responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, cause);
                }
            } else if (e instanceof DispatchException) {
                responseMessage = ((DispatchException)e).fault;
            } else {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
                responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
            }
        }
//        return req.createServerResponse(responseMessage, req.endpoint.getPort(), javaMethodModel.getOwner(), req.endpoint.getBinding());

        return responseMessage;
    }
 
Example #26
Source File: VersionMismatchException.java    From hottub 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 #27
Source File: TieHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Message createResponse(JavaCallInfo call) {
        Message responseMessage;
        if (call.getException() == null) {
            responseMessage = isOneWay ? null : createResponseMessage(call.getParameters(), call.getReturnValue());
        } else {
            Throwable e = call.getException();
            Throwable serviceException = getServiceException(e);
            if (e instanceof InvocationTargetException || serviceException != null) {
//              Throwable cause = e.getCause();
              //if (!(cause instanceof RuntimeException) && cause instanceof Exception) {
                if (serviceException != null) {
                    // Service specific exception
                    LOGGER.log(Level.FINE, serviceException.getMessage(), serviceException);
                    responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion,
                            javaMethodModel.getCheckedException(serviceException.getClass()), serviceException);
                } else {
                    Throwable cause = e.getCause();
                    if (cause instanceof ProtocolException) {
                        // Application code may be throwing it intentionally
                        LOGGER.log(Level.FINE, cause.getMessage(), cause);
                    } else {
                        // Probably some bug in application code
                        LOGGER.log(Level.SEVERE, cause.getMessage(), cause);
                    }
                    responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, cause);
                }
            } else if (e instanceof DispatchException) {
                responseMessage = ((DispatchException)e).fault;
            } else {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
                responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
            }
        }
//        return req.createServerResponse(responseMessage, req.endpoint.getPort(), javaMethodModel.getOwner(), req.endpoint.getBinding());

        return responseMessage;
    }
 
Example #28
Source File: StubHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public JavaCallInfo readResponse(Packet p, JavaCallInfo call) throws Throwable {
        Message msg = p.getMessage();
if(msg.isFault()) {
    SOAPFaultBuilder faultBuilder = SOAPFaultBuilder.create(msg);
    Throwable t = faultBuilder.createException(checkedExceptions);
    call.setException(t);
    throw t;
} else {
        initArgs(call.getParameters());
    Object ret = responseBuilder.readResponse(msg, call.getParameters());
    call.setReturnValue(ret);
    return call;
}
}
 
Example #29
Source File: Messages.java    From openjdk-8 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: TieHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Message createResponse(JavaCallInfo call) {
        Message responseMessage;
        if (call.getException() == null) {
            responseMessage = isOneWay ? null : createResponseMessage(call.getParameters(), call.getReturnValue());
        } else {
            Throwable e = call.getException();
            Throwable serviceException = getServiceException(e);
            if (e instanceof InvocationTargetException || serviceException != null) {
//              Throwable cause = e.getCause();
              //if (!(cause instanceof RuntimeException) && cause instanceof Exception) {
                if (serviceException != null) {
                    // Service specific exception
                    LOGGER.log(Level.FINE, serviceException.getMessage(), serviceException);
                    responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion,
                            javaMethodModel.getCheckedException(serviceException.getClass()), serviceException);
                } else {
                    Throwable cause = e.getCause();
                    if (cause instanceof ProtocolException) {
                        // Application code may be throwing it intentionally
                        LOGGER.log(Level.FINE, cause.getMessage(), cause);
                    } else {
                        // Probably some bug in application code
                        LOGGER.log(Level.SEVERE, cause.getMessage(), cause);
                    }
                    responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, cause);
                }
            } else if (e instanceof DispatchException) {
                responseMessage = ((DispatchException)e).fault;
            } else {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
                responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
            }
        }
//        return req.createServerResponse(responseMessage, req.endpoint.getPort(), javaMethodModel.getOwner(), req.endpoint.getBinding());

        return responseMessage;
    }