Search in sources :

Example 51 with WebServiceException

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

the class HelloImpl method validateDataHandler.

private void validateDataHandler(int expTotal, DataHandler dh) throws IOException {
    // readOnce() doesn't store attachment on the disk in some cases
    // for e.g when only one attachment is in the message
    StreamingDataHandler sdh = (StreamingDataHandler) dh;
    InputStream in = sdh.readOnce();
    byte[] buf = new byte[8192];
    int total = 0;
    int len;
    while ((len = in.read(buf, 0, buf.length)) != -1) {
        for (int i = 0; i < len; i++) {
            if ((byte) ('A' + (total + i) % 26) != buf[i]) {
                throw new WebServiceException("DataHandler data is different");
            }
        }
        total += len;
        if (total % (8192 * 250) == 0) {
            System.out.println("Total so far=" + total);
        }
    }
    in.close();
    sdh.close();
    if (total != expTotal) {
        throw new WebServiceException("DataHandler data size is different");
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) StreamingDataHandler(com.sun.xml.ws.developer.StreamingDataHandler)

Example 52 with WebServiceException

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

the class HelloImpl method validateDataHandler.

private void validateDataHandler(int expTotal, DataHandler dh) throws IOException {
    // readOnce() doesn't store attachment on the disk in some cases
    // for e.g when only one attachment is in the message
    StreamingDataHandler sdh = (StreamingDataHandler) dh;
    InputStream in = sdh.readOnce();
    byte[] buf = new byte[8192];
    int total = 0;
    int len;
    while ((len = in.read(buf, 0, buf.length)) != -1) {
        for (int i = 0; i < len; i++) {
            if ((byte) ('A' + (total + i) % 26) != buf[i]) {
                throw new WebServiceException("DataHandler data is different");
            }
        }
        total += len;
        if (total % (8192 * 250) == 0) {
            System.out.println("Total so far=" + total);
        }
    }
    in.close();
    sdh.close();
    if (total != expTotal) {
        throw new WebServiceException("DataHandler data size is different");
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) StreamingDataHandler(com.sun.xml.ws.developer.StreamingDataHandler)

Example 53 with WebServiceException

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

the class XMLHTTPBindingCodec method transformDataSource.

public static DataSource transformDataSource(DataSource in, boolean isFastInfoset, boolean useFastInfoset, WSFeatureList f) {
    try {
        if (isFastInfoset && !useFastInfoset) {
            // Convert from Fast Infoset to XML
            Codec codec = new XMLHTTPBindingCodec(f);
            Packet p = new Packet();
            codec.decode(in.getInputStream(), in.getContentType(), p);
            p.getMessage().getAttachments();
            codec.getStaticContentType(p);
            ByteArrayBuffer bos = new ByteArrayBuffer();
            ContentType ct = codec.encode(p, bos);
            return XMLMessage.createDataSource(ct.getContentType(), bos.newInputStream());
        } else if (!isFastInfoset && useFastInfoset) {
            // Convert from XML to Fast Infoset
            Codec codec = new XMLHTTPBindingCodec(f);
            Packet p = new Packet();
            codec.decode(in.getInputStream(), in.getContentType(), p);
            p.contentNegotiation = ContentNegotiation.optimistic;
            p.getMessage().getAttachments();
            codec.getStaticContentType(p);
            ByteArrayBuffer bos = new ByteArrayBuffer();
            com.sun.xml.ws.api.pipe.ContentType ct = codec.encode(p, bos);
            return XMLMessage.createDataSource(ct.getContentType(), bos.newInputStream());
        }
    } catch (Exception ex) {
        throw new WebServiceException(ex);
    }
    return in;
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Codec(com.sun.xml.ws.api.pipe.Codec) XMLCodec(com.sun.xml.ws.encoding.xml.XMLCodec) ContentType(com.sun.xml.ws.api.pipe.ContentType) WebServiceException(jakarta.xml.ws.WebServiceException) IOException(java.io.IOException) WebServiceException(jakarta.xml.ws.WebServiceException) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer)

Example 54 with WebServiceException

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

the class DatabindingFactoryImpl method loadPropertiesFile.

Properties loadPropertiesFile(String fileName) {
    ClassLoader classLoader = classLoader();
    Properties p = new Properties();
    try {
        InputStream is = null;
        if (classLoader == null) {
            is = ClassLoader.getSystemResourceAsStream(fileName);
        } else {
            is = classLoader.getResourceAsStream(fileName);
        }
        if (is != null) {
            p.load(is);
        }
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
    return p;
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) InputStream(java.io.InputStream) Properties(java.util.Properties) WebServiceException(jakarta.xml.ws.WebServiceException)

Example 55 with WebServiceException

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

the class DispatchHelloLiteralTest method kkktestHelloAsyncHandlerCancelInterruptJAXB.

/* public void testHelloAsyncHandlerCancelJAXB() {

        JAXBContext jc = null;
        Hello_Type hello = null;

        try {
            jc = createJAXBContext();
            hello = new Hello_Type();

        } catch (Exception jbe) {
            jbe.printStackTrace();
        }

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

            Dispatch dispatch = getDispatchJAXB();

            JAXBAsyncHandler handler = new JAXBAsyncHandler(hello);
            Future result = dispatch.invokeAsync(hello, handler);
            try {
                System.out.println("Response retured to test Thread " + Thread.currentThread().getId());
                System.out.println("Response " + result.getClass().getName());
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            while (!result.isDone()) {
                System.out.println("Not done");
                result.cancel(false);
                assertTrue(result.isCancelled());
                System.out.println("Canceled result");
            }

        } catch (WebServiceException e) {
            e.printStackTrace();
        }
    }
   */
public void kkktestHelloAsyncHandlerCancelInterruptJAXB() {
    JAXBContext jc = null;
    Hello_Type hello = null;
    try {
        jc = createJAXBContext();
        hello = new Hello_Type();
    } catch (Exception jbe) {
        jbe.printStackTrace();
    }
    hello.setExtra("Test ");
    hello.setArgument("Dispatch ");
    Dispatch dispatch = getDispatchJAXB();
    JAXBAsyncHandler handler = new JAXBAsyncHandler(hello);
    Future result = dispatch.invokeAsync(hello, handler);
    while (!result.isDone()) {
        result.cancel(true);
        assertTrue(result.isCancelled());
        System.out.println("Cancel interupt passed");
    }
}
Also used : Dispatch(jakarta.xml.ws.Dispatch) Future(java.util.concurrent.Future) JAXBContext(jakarta.xml.bind.JAXBContext) WebServiceException(jakarta.xml.ws.WebServiceException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Aggregations

WebServiceException (jakarta.xml.ws.WebServiceException)396 QName (javax.xml.namespace.QName)50 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)38 SOAPException (jakarta.xml.soap.SOAPException)35 JAXBException (jakarta.xml.bind.JAXBException)30 IOException (java.io.IOException)30 Node (org.w3c.dom.Node)29 JAXBContext (jakarta.xml.bind.JAXBContext)27 SOAPMessage (jakarta.xml.soap.SOAPMessage)26 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 URL (java.net.URL)18 Map (java.util.Map)18 MessageContext (jakarta.xml.ws.handler.MessageContext)17 StreamSource (javax.xml.transform.stream.StreamSource)17 HandlerTracker (fromwsdl.handler.common.HandlerTracker)14 HandlerTracker (handler.handler_processing.common.HandlerTracker)14