Search in sources :

Example 16 with Dispatch

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

the class DispatchHello method testNoParamHelloRequestResponseJAXB.

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 WebServiceException);
        System.out.println("NoParamHelloRequestResponseJAXB PASSED");
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) JAXBException(jakarta.xml.bind.JAXBException) Dispatch(jakarta.xml.ws.Dispatch) JAXBContext(jakarta.xml.bind.JAXBContext) MalformedURLException(java.net.MalformedURLException) WebServiceException(jakarta.xml.ws.WebServiceException) JAXBException(jakarta.xml.bind.JAXBException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 17 with Dispatch

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

the class DispatchHello method testSQETestXML.

public void testSQETestXML() throws WebServiceException, Exception {
    // System.err.println("----------------Expected Message ----------------------");
    Dispatch dispatch = getDispatchSource();
    Source source = null;
    Source response = null;
    try {
        source = makeStreamSource(sqeTest);
    } catch (Exception e) {
        System.out.println("Error making msg source exiting");
    }
    try {
        Object result = dispatch.invoke(source);
        String xmlResult = sourceToXMLString((Source) result);
        System.out.println("Got result : " + xmlResult);
        assertTrue(result == null);
        System.out.println("sqeXML Passed");
    } catch (Exception ex) {
        assertTrue(ex instanceof SOAPFaultException);
    }
// System.err.println("----------------END Expected Message ----------------------");
}
Also used : Dispatch(jakarta.xml.ws.Dispatch) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) Source(javax.xml.transform.Source) MalformedURLException(java.net.MalformedURLException) WebServiceException(jakarta.xml.ws.WebServiceException) JAXBException(jakarta.xml.bind.JAXBException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 18 with Dispatch

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

the class DispatchHello method testDispatchPropertySoapUseAction.

public void testDispatchPropertySoapUseAction() {
    try {
        Dispatch dispatch = getDispatchSource();
        Source source = makeStreamSource(helloMsg);
        List<Handler> handlerchain = new ArrayList<Handler>();
        handlerchain.add(new MyHandler());
        dispatch.getBinding().setHandlerChain(handlerchain);
        dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
        dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "urn:test:hello_mod");
        Object result = dispatch.invoke(source);
        assertTrue(result instanceof Source);
        String xmlResult = sourceToXMLString((Source) result);
        System.out.println("Got result : " + xmlResult);
    // tbd update assertion
    } catch (Exception ex) {
        fail("SOAPAction test fails");
    }
}
Also used : Dispatch(jakarta.xml.ws.Dispatch) Handler(jakarta.xml.ws.handler.Handler) SOAPHandler(jakarta.xml.ws.handler.soap.SOAPHandler) Source(javax.xml.transform.Source) MalformedURLException(java.net.MalformedURLException) WebServiceException(jakarta.xml.ws.WebServiceException) JAXBException(jakarta.xml.bind.JAXBException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 19 with Dispatch

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

the class DispatchHello method testHelloRequestResponseJAXB.

public void testHelloRequestResponseJAXB() throws Exception {
    JAXBContext jc = null;
    HelloResponse helloResult = null;
    Hello_Type hello = new Hello_Type();
    jc = createJAXBContext();
    try {
        hello.setArgument("foo");
        hello.setExtra("Test ");
        Dispatch dispatch = getDispatchJAXB();
        Object result = dispatch.invoke(hello);
        assertEquals(((HelloResponse) result).getExtra(), hello.getExtra());
        assertEquals(((HelloResponse) result).getArgument(), hello.getArgument());
    } catch (WebServiceException jex) {
        jex.printStackTrace();
        fail("testHelloRequestResponseJAXB FAILED");
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) Dispatch(jakarta.xml.ws.Dispatch) JAXBContext(jakarta.xml.bind.JAXBContext)

Example 20 with Dispatch

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

the class DispatchHelloLiteralTest method testHelloAsyncPollSOAPMessage.

public void testHelloAsyncPollSOAPMessage() throws Exception {
    Dispatch dispatch = getDispatchSOAPMessage();
    SOAPMessage msg = getSOAPMessage(makeStreamSource(helloSM));
    try {
        Response<SOAPMessage> result = dispatch.invokeAsync(msg);
        assertTrue(result != null);
        SOAPMessage resultmsg = result.get();
        assertTrue(resultmsg != null);
        System.out.println("-----------------------------------------");
        System.out.println("SOAPMessage Result = ");
        resultmsg.writeTo(System.out);
        System.out.println("-----------------------------------------");
    } catch (Exception e) {
        e.printStackTrace();
        fail("Test fails");
    }
}
Also used : Dispatch(jakarta.xml.ws.Dispatch) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Aggregations

Dispatch (jakarta.xml.ws.Dispatch)97 WebServiceException (jakarta.xml.ws.WebServiceException)41 Source (javax.xml.transform.Source)32 JAXBContext (jakarta.xml.bind.JAXBContext)30 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)27 MalformedURLException (java.net.MalformedURLException)24 JAXBException (jakarta.xml.bind.JAXBException)22 StreamSource (javax.xml.transform.stream.StreamSource)18 Service (jakarta.xml.ws.Service)16 DOMSource (javax.xml.transform.dom.DOMSource)13 SAXSource (javax.xml.transform.sax.SAXSource)13 InputSource (org.xml.sax.InputSource)13 SOAPMessage (jakarta.xml.soap.SOAPMessage)10 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)10 SAXException (org.xml.sax.SAXException)10 Response (jakarta.xml.ws.Response)9 Iterator (java.util.Iterator)8 URISyntaxException (java.net.URISyntaxException)7 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)6 WSBindingProvider (com.sun.xml.ws.developer.WSBindingProvider)6