Search in sources :

Example 91 with WebServiceException

use of jakarta.xml.ws.WebServiceException 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 92 with WebServiceException

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

the class DispatchHello method testHelloRequestResponseJAXBWPorts.

public void testHelloRequestResponseJAXBWPorts() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("http transport only exiting");
        return;
    }
    JAXBContext jc = null;
    HelloResponse result = null;
    Hello_Type hello = new Hello_Type();
    jc = createJAXBContext();
    try {
        hello.setArgument("foo");
        hello.setExtra("Test ");
        Dispatch dispatch = getDispatchJAXBWithPorts();
        result = (HelloResponse) dispatch.invoke(hello);
        assertEquals(((HelloResponse) result).getExtra(), hello.getExtra());
        assertEquals(((HelloResponse) result).getArgument(), hello.getArgument());
    } catch (WebServiceException jex) {
        fail("testHelloRequestResponseJAXB FAILED");
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) Dispatch(jakarta.xml.ws.Dispatch) JAXBContext(jakarta.xml.bind.JAXBContext)

Example 93 with WebServiceException

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

the class DispatchHello method testHelloRequestResponseJAXBPortsAvailable.

public void testHelloRequestResponseJAXBPortsAvailable() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("http transport only exiting");
        return;
    }
    JAXBContext jc = null;
    HelloResponse helloResult = null;
    Hello_Type hello = new Hello_Type();
    jc = createJAXBContext();
    try {
        hello.setArgument("foo");
        hello.setExtra("Test ");
        Dispatch dispatch = getDispatchJAXBWithPorts();
        Object result = dispatch.invoke(hello);
        assertEquals(((HelloResponse) result).getExtra(), hello.getExtra());
        assertEquals(((HelloResponse) result).getArgument(), hello.getArgument());
    } catch (WebServiceException jex) {
        fail("testHelloRequestResponseJAXB FAILED");
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) Dispatch(jakarta.xml.ws.Dispatch) JAXBContext(jakarta.xml.bind.JAXBContext)

Example 94 with WebServiceException

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

the class DispatchHello method xxtestHelloRequestResponseJAXBWPorts.

public void xxtestHelloRequestResponseJAXBWPorts() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("http transport only exiting");
        return;
    }
    JAXBContext jc = null;
    HelloResponse result = null;
    Hello_Type hello = new Hello_Type();
    jc = createJAXBContext();
    try {
        hello.setArgument("foo");
        hello.setExtra("Test ");
        Dispatch dispatch = getDispatchJAXBWithPorts();
        result = (HelloResponse) dispatch.invoke(hello);
        assertEquals(((HelloResponse) result).getExtra(), hello.getExtra());
        assertEquals(((HelloResponse) result).getArgument(), hello.getArgument());
    } catch (WebServiceException jex) {
        fail("testHelloRequestResponseJAXB FAILED");
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) Dispatch(jakarta.xml.ws.Dispatch) JAXBContext(jakarta.xml.bind.JAXBContext)

Example 95 with WebServiceException

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

the class HelloAsyncImpl method invoke.

@Override
public void invoke(Source source, AsyncProviderCallback<Source> cbak, WebServiceContext ctxt) {
    System.out.println("**** Received in AsyncProvider Impl ******");
    try {
        Hello_Type hello = recvBean(source);
        String arg = hello.getArgument();
        if (arg.equals("sync")) {
            String extra = hello.getExtra();
            if (extra.equals("source")) {
                cbak.send(sendSource());
            } else if (extra.equals("bean")) {
                cbak.send(sendBean());
            } else {
                throw new WebServiceException("Expected extra = (source|bean|fault), Got=" + extra);
            }
        } else if (arg.equals("async")) {
            new Thread(new RequestHandler(cbak, hello)).start();
        } else {
            throw new WebServiceException("Expected Argument = (sync|async), Got=" + arg);
        }
    } catch (Exception e) {
        throw new WebServiceException("Endpoint failed", e);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) JAXBException(jakarta.xml.bind.JAXBException) 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