Search in sources :

Example 11 with Dispatch

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

the class DispatchHello method kkktestBad3HelloRequestResponseXML.

// bad namespace- expect SFE
public void kkktestBad3HelloRequestResponseXML() {
    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) {
        try {
            assertTrue(e instanceof SOAPFaultException);
            System.out.println("testBad3HelloRequestResponseXML Passed");
        } catch (Exception ex) {
            System.err.println("Expected SOAPFAULTException - got " + ex.getClass().getName());
            System.out.println("testBad3HelloRequestResponseXML FAILED");
            fail("testBad3HelloRequestResponseXML FAILED");
        }
    }
}
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 12 with Dispatch

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

the class DispatchHello method testHelloRequestResponseSOAPMessageSource.

public void testHelloRequestResponseSOAPMessageSource() throws Exception {
    Dispatch dispatch = getDispatchSOAPMessageSource();
    Source source = makeStreamSource(helloSM);
    Object result = dispatch.invoke(source);
    System.out.println("Result class is " + result.getClass().getName());
    // todo: need to check contents
    assertTrue(result instanceof Source);
}
Also used : Dispatch(jakarta.xml.ws.Dispatch) Source(javax.xml.transform.Source)

Example 13 with Dispatch

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

the class DispatchHello method testHelloRequestResponseSOAPMessage.

public void testHelloRequestResponseSOAPMessage() throws Exception {
    Dispatch dispatch = getDispatchSOAPMessage();
    assertTrue(dispatch != null);
    assertTrue(dispatch instanceof com.sun.xml.ws.client.dispatch.SOAPMessageDispatch);
    byte[] bytes = helloSM.getBytes();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
    Source source = makeStreamSource(helloSM);
    SOAPMessage message = getSOAPMessage(source);
    Object result = dispatch.invoke(message);
    // todo:need to check contents
    assertTrue(result instanceof SOAPMessage);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Dispatch(jakarta.xml.ws.Dispatch) SOAPMessage(jakarta.xml.soap.SOAPMessage) Source(javax.xml.transform.Source)

Example 14 with Dispatch

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

the class DispatchHello method testHelloRequestResponseXML.

public void testHelloRequestResponseXML() throws Exception {
    Dispatch dispatch = getDispatchSource();
    assertTrue(dispatch != null);
    /*  Source request = makeStreamSource(helloMsg);
        Object result = dispatch.invoke(request);
        assertTrue(result instanceof Source);
        String xmlResult = sourceToXMLString((Source) result);
        System.out.println("Got result : " + xmlResult);
       */
    /*
        Does not work with out source types-ie DomSource, saxSource
        */
    Collection<Source> sourceList = makeMsgSource(helloMsg);
    Collection<Source> responseList = makeMsgSource(helloResponse);
    try {
        for (Iterator iter = sourceList.iterator(); iter.hasNext(); ) {
            Object sourceObject = iter.next();
            Object result = dispatch.invoke(sourceObject);
            assertTrue(result instanceof Source);
            String xmlResult = sourceToXMLString((Source) result);
            System.out.println("Got result : " + xmlResult);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("testHelloRequestResponseXML FAILED");
    }
}
Also used : Dispatch(jakarta.xml.ws.Dispatch) 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 15 with Dispatch

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

the class DispatchHello method kktestHelloRequestResponseHelloMsgBadFooXML.

// needs to be looked at
public void kktestHelloRequestResponseHelloMsgBadFooXML() {
    // test for bug6323952
    Dispatch dispatch = getDispatchSource();
    Source source = makeStreamSource(helloMsgBadFoo);
    Source response = makeStreamSource(helloResponse);
    try {
        Source result = (Source) dispatch.invoke(source);
        // assertTrue(result == null);
        // printout result
        // in actuality a soapFaultMessage need to be returned.
        String xmlResult = sourceToXMLString(result);
        System.out.println("Got result : " + xmlResult);
    } catch (Exception e) {
        try {
            assertTrue(e instanceof SOAPFaultException);
            SOAPFaultException sfe = (SOAPFaultException) e;
            if (sfe.getMessage() != null)
                System.out.println("sfe message " + sfe.getMessage());
            System.out.println("e class " + e.getClass().getName());
            if (e.getCause() != null)
                System.out.println("Cause is " + e.getCause().getClass().getName());
            // assertTrue(e instanceof SOAPFaultException);
            System.out.println("testHelloRequestBadFooResponseXML Passed");
        } catch (Exception ex) {
            System.err.println("Expected SOAPFAULTException - got " + ex.getClass().getName());
            System.out.println("testHelloRequestBadFooResponseXML FAILED");
            fail("testHelloRequestBadFooResponseXML FAILED");
        }
    }
}
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)

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