Search in sources :

Example 11 with SOAPFaultException

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

the class AddNumbersClient method testEPRGetPortVIIIII.

public void testEPRGetPortVIIIII() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    AddNumbersPortType proxy = createStub();
    EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
    RespectBindingFeature feature = new RespectBindingFeature(true);
    MemberSubmissionAddressingFeature addr = new MemberSubmissionAddressingFeature(true, true);
    WebServiceFeature[] features = new WebServiceFeature[] { feature, addr };
    AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
    assertTrue(port != null);
    try {
        System.out.println("Adding numbers 2 and 4");
        int result = port.addNumbers(2, 4);
        assertFalse(result == 6);
    } catch (Exception ex) {
        assertTrue(ex instanceof SOAPFaultException);
        System.out.println(((SOAPFaultException) ex).getFault().getFaultString());
    }
}
Also used : SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 12 with SOAPFaultException

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

the class DispatchHeaderTest method testEchoSource.

public void testEchoSource() throws Exception {
    init(endpointAddress, portQName, serviceQName, null);
    Source source = makeStreamSource(echoRequest);
    Dispatch dispatch = getDispatchSource();
    try {
        System.err.println("************Expected EXCEPTION***************");
        Object result = dispatch.invoke(source);
        assertTrue(result == null);
    } catch (Exception sfe) {
        System.err.println("************End Expected EXCEPTION***************");
        assertTrue(sfe instanceof SOAPFaultException);
    }
}
Also used : Dispatch(jakarta.xml.ws.Dispatch) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) JAXBException(jakarta.xml.bind.JAXBException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 13 with SOAPFaultException

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

the class DispatchHelloClientTest method testNoParamHelloRequestResponseJAXBNegative.

// should send empty SOAPBody here - no argument returned or perhaps server side exception
// nillable allowed message
public void testNoParamHelloRequestResponseJAXBNegative() throws Throwable {
    JAXBContext jc = null;
    HelloRequest hello = null;
    HelloResponse helloResult = null;
    try {
        jc = createJAXBContext();
    } catch (Exception jbe) {
        fail("Problem creating jaxb context");
    }
    try {
        // no hello args
        Dispatch dispatch = getDispatchJAXB();
        Object result = dispatch.invoke(null);
        assertTrue(result == null);
    } catch (Exception e) {
        assertTrue(e instanceof SOAPFaultException);
        System.out.println("NoParamHelloRequestResponseJAXBNegative PASSED");
    }
}
Also used : HelloResponse(client.dispatch.null_jaxb.client.HelloResponse) HelloRequest(client.dispatch.null_jaxb.client.HelloRequest) Dispatch(jakarta.xml.ws.Dispatch) JAXBContext(jakarta.xml.bind.JAXBContext) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) MalformedURLException(java.net.MalformedURLException) WebServiceException(jakarta.xml.ws.WebServiceException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 14 with SOAPFaultException

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

the class DispatchHello method testNoParamHelloRequestResponseJAXB.

// todo:investigate failed assertion bad JAXB message should fail after invocation RemoteException?
/* public void testHelloResponseBadRequestResponseJAXB() throws Throwable {

          JAXBContext jc = null;
          NameType hello = null;
          HelloResponse helloResult = null;

          jc = createJAXBContext();
          hello = new NameType();
          helloResult = new HelloResponse();

          try {
              //no remote method
              hello.getName().add("foo");

              Dispatch dispatch = getDispatchJAXB();

              Object result = dispatch.invoke(hello);
              System.out.println(" testHelloResponseBadRequestResponseJAXB FAILED");
          } catch (Exception e) {
              try {
              assertTrue(e instanceof SOAPFaultException);
              //assertTrue(e.getCause() instanceof SOAPFaultException);
              System.out.println(" testHelloResponseBadRequestResponseJAXB PASSED");
              } catch (Exception ex){
                System.out.println(" testHelloResponseBadRequestResponseJAXB FAILED");
              }
          }
      }
    */
// todo:Investigate failed assertion invoking Result not request - expect remoteException w/SOAPFailtEx
/*  public void testHelloResponseBad2RequestResponseJAXB() throws Throwable {

          JAXBContext jc = null;
          HelloResponse helloResult = null;

          try {
              jc = createJAXBContext();
              helloResult = new HelloResponse();
          } catch (Exception jbe) {
              jbe.printStackTrace();
          }

          try {
              helloResult.setExtra("Test ");
              helloResult.setArgument("Dispatch ");

              Dispatch dispatch = getDispatchJAXB();

              Object result = dispatch.invoke(helloResult);
              System.out.println(" testHelloResponseBadRequestResponseJAXB FAILED");
          } catch (Exception e) {
              try {
              assertTrue(e instanceof SOAPFaultException);
              //assertTrue(e.getCause() instanceof SOAPFaultException);
              System.out.println(" testHelloResponseBad3RequestResponseJAXB PASSED");
              } catch (Exception ex){
                 System.out.println(" testHelloResponseBadRequestResponseJAXB FAILED");
              }
          }
      }
      */
public void testNoParamHelloRequestResponseJAXB() throws Throwable {
    JAXBContext jc = null;
    Hello_Type hello = null;
    HelloResponse helloResult = null;
    try {
        jc = createJAXBContext();
        hello = new Hello_Type();
        helloResult = new HelloResponse();
    } catch (Exception jbe) {
        assertTrue(jbe instanceof JAXBException);
    }
    try {
        // no hello args
        Dispatch dispatch = getDispatchJAXB();
        Object result = dispatch.invoke(null);
        assertTrue(result == null);
    // System.out.println("NoParamHelloRequestResponseJAXB FAILED");
    } catch (Exception e) {
        assertTrue(e instanceof SOAPFaultException);
        System.out.println("no param result is " + e.getClass().getName());
        // assertTrue(e instanceof WebServiceException);
        System.out.println("NoParamHelloRequestResponseJAXB PASSED");
    }
}
Also used : JAXBException(jakarta.xml.bind.JAXBException) Dispatch(jakarta.xml.ws.Dispatch) JAXBContext(jakarta.xml.bind.JAXBContext) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) MalformedURLException(java.net.MalformedURLException) URISyntaxException(java.net.URISyntaxException) WebServiceException(jakarta.xml.ws.WebServiceException) JAXBException(jakarta.xml.bind.JAXBException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 15 with SOAPFaultException

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

the class DispatchHello method testBad3HelloRequestResponseXML.

// bad namespace- expect remote exception
public void testBad3HelloRequestResponseXML() {
    Dispatch dispatch = getDispatchSource();
    Source source = makeStreamSource(bad3helloMsg);
    Source response = makeStreamSource(helloResponse);
    try {
        Object result = dispatch.invoke(source);
        assertTrue(result == null);
        System.out.println("B3HelloRR invoke succeded");
    } catch (Exception e) {
        assertTrue(e instanceof SOAPFaultException);
        System.out.println("testBad3HelloRequestResponseXML Passed");
    }
}
Also used : Dispatch(jakarta.xml.ws.Dispatch) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) Source(javax.xml.transform.Source) MalformedURLException(java.net.MalformedURLException) URISyntaxException(java.net.URISyntaxException) WebServiceException(jakarta.xml.ws.WebServiceException) JAXBException(jakarta.xml.bind.JAXBException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

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