Search in sources :

Example 16 with SOAPFaultException

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

the class WsaTestImpl method echo.

public String echo(String param) {
    System.out.println(NAME + ".echo: " + param);
    String message = null;
    if (param.equals(""))
        message = "The echo string was empty";
    if (param.startsWith("fault"))
        message = "\"" + param + "\" triggered the fault";
    if (message != null)
        throw new SOAPFaultException(createSOAPFault(message));
    return param;
}
Also used : SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 17 with SOAPFaultException

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

the class AddNumbersClient method testInvalidReplyTo.

public void testInvalidReplyTo() throws Exception {
    try {
        SOAPMessage response = WsaUtils.invoke(createDispatchWithoutWSDL(), WsaUtils.INVALID_REPLY_TO_MESSAGE, WsaUtils.S11_NS, WsaUtils.W3C_WSA_NS, getAddress(), "WRONG", W3CAddressingConstants.WSA_ANONYMOUS_ADDRESS, CORRECT_ACTION);
        fail("SOAPFaultException must be thrown");
    } catch (SOAPFaultException sfe) {
        assertTrue("Got SOAPFaultException", true);
    }
}
Also used : SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 18 with SOAPFaultException

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

the class WsaTestImpl method echo.

public String echo(String param) {
    System.out.println(NAME + ".echo: " + param);
    String message = null;
    if (param.equals(""))
        message = "The echo string was empty";
    if (param.startsWith("fault"))
        message = "\"" + param + "\" triggered the fault";
    if (message != null)
        throw new SOAPFaultException(createSOAPFault(message));
    return param;
}
Also used : SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 19 with SOAPFaultException

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

the class MUTest method testMU_SOAP11.

public void testMU_SOAP11() throws Exception {
    QName portQName = new QName("http://server.mu_header_fault.server/", "TestEndpointPort");
    Dispatch<SOAPMessage> dispatch = new TestEndpointService().createDispatch(portQName, SOAPMessage.class, Service.Mode.MESSAGE);
    SOAPMessage message = getSOAPMessage(makeStreamSource(s11_request));
    try {
        Object result = dispatch.invoke(message);
    } catch (SOAPFaultException e) {
        SOAPFault sf = e.getFault();
        assertTrue(sf.getFaultCode().endsWith(":MustUnderstand"));
        NodeList nl = ((Element) sf).getChildNodes();
        int codeIndex = indexOf(new QName("", "faultcode"), nl);
        int reasonIndex = indexOf(new QName("", "faultstring"), nl);
        assertTrue("<faultcode> and <faultstring> are not in proper order", codeIndex < reasonIndex);
    }
}
Also used : QName(javax.xml.namespace.QName) NodeList(org.w3c.dom.NodeList) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 20 with SOAPFaultException

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

the class HandlerUtil method throwSOAPFaultException.

boolean throwSOAPFaultException(MessageContext context, String name, String direction) {
    Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if ((outbound == Boolean.TRUE && direction.equals(INBOUND)) || (outbound == Boolean.FALSE && direction.equals(OUTBOUND))) {
        // not the direction we want
        return true;
    }
    // random info in soap fault
    try {
        QName faultCode = new QName("uri", "local", "prefix");
        String faultString = "fault";
        String faultActor = "faultActor";
        SOAPFault sf = SOAPFactory.newInstance().createFault(faultString, faultCode);
        sf.setFaultActor(faultActor);
        Detail detail = sf.addDetail();
        Name entryName = SOAPFactory.newInstance().createName("someFaultEntry");
        detail.addDetailEntry(entryName);
        throw new SOAPFaultException(sf);
    } catch (SOAPException e) {
        throw new RuntimeException("Couldn't create SOAPFaultException " + e);
    }
}
Also used : QName(javax.xml.namespace.QName) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) QName(javax.xml.namespace.QName)

Aggregations

SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)105 QName (javax.xml.namespace.QName)28 WebServiceException (jakarta.xml.ws.WebServiceException)27 SOAPFault (jakarta.xml.soap.SOAPFault)21 JAXBException (jakarta.xml.bind.JAXBException)16 Dispatch (jakarta.xml.ws.Dispatch)16 MemberSubmissionAddressingFeature (com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)14 MemberSubmissionEndpointReference (com.sun.xml.ws.developer.MemberSubmissionEndpointReference)12 W3CEndpointReference (jakarta.xml.ws.wsaddressing.W3CEndpointReference)12 MalformedURLException (java.net.MalformedURLException)12 Source (javax.xml.transform.Source)12 HandlerTracker (fromwsdl.handler.common.HandlerTracker)11 HandlerTracker (handler.handler_processing.common.HandlerTracker)11 AddressingFeature (jakarta.xml.ws.soap.AddressingFeature)10 Message (com.sun.xml.ws.api.message.Message)9 SAAJMessage (com.sun.xml.ws.message.saaj.SAAJMessage)9 ProtocolException (jakarta.xml.ws.ProtocolException)9 IOException (java.io.IOException)7 SOAPMessage (jakarta.xml.soap.SOAPMessage)6 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)5