Search in sources :

Example 1 with JMSMTOMPortType

use of org.apache.cxf.jms_mtom.JMSMTOMPortType in project cxf by apache.

the class JMSTestMtom method testOutMTOM.

@Test
public void testOutMTOM() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/jms_mtom", "JMSMTOMService");
    QName portName = new QName("http://cxf.apache.org/jms_mtom", "MTOMPort");
    URL wsdl = getWSDLURL("/wsdl/jms_test_mtom.wsdl");
    JMSOutMTOMService service = new JMSOutMTOMService(wsdl, serviceName);
    JMSMTOMPortType mtom = service.getPort(portName, JMSMTOMPortType.class);
    URL fileURL = this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class");
    DataHandler handler1 = new DataHandler(fileURL);
    int size = handler1.getInputStream().available();
    DataHandler ret = mtom.testOutMtom();
    byte[] bytes = IOUtils.readBytesFromStream(ret.getInputStream());
    Assert.assertEquals("The response file is not same with the original file.", size, bytes.length);
    ((Closeable) mtom).close();
}
Also used : JMSOutMTOMService(org.apache.cxf.jms_mtom.JMSOutMTOMService) QName(javax.xml.namespace.QName) Closeable(java.io.Closeable) JMSMTOMPortType(org.apache.cxf.jms_mtom.JMSMTOMPortType) DataHandler(javax.activation.DataHandler) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Example 2 with JMSMTOMPortType

use of org.apache.cxf.jms_mtom.JMSMTOMPortType in project cxf by apache.

the class JMSTestMtom method testMTOM.

@Test
public void testMTOM() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/jms_mtom", "JMSMTOMService");
    QName portName = new QName("http://cxf.apache.org/jms_mtom", "MTOMPort");
    URL wsdl = getWSDLURL("/wsdl/jms_test_mtom.wsdl");
    JMSMTOMService service = new JMSMTOMService(wsdl, serviceName);
    JMSMTOMPortType mtom = service.getPort(portName, JMSMTOMPortType.class);
    Binding binding = ((BindingProvider) mtom).getBinding();
    ((SOAPBinding) binding).setMTOMEnabled(true);
    Holder<String> name = new Holder<>("Sam");
    URL fileURL = this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class");
    Holder<DataHandler> handler1 = new Holder<>();
    handler1.value = new DataHandler(fileURL);
    int size = handler1.value.getInputStream().available();
    mtom.testDataHandler(name, handler1);
    byte[] bytes = IOUtils.readBytesFromStream(handler1.value.getInputStream());
    Assert.assertEquals("The response file is not same with the sent file.", size, bytes.length);
    ((Closeable) mtom).close();
}
Also used : Binding(javax.xml.ws.Binding) SOAPBinding(javax.xml.ws.soap.SOAPBinding) QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) Closeable(java.io.Closeable) SOAPBinding(javax.xml.ws.soap.SOAPBinding) JMSMTOMPortType(org.apache.cxf.jms_mtom.JMSMTOMPortType) BindingProvider(javax.xml.ws.BindingProvider) DataHandler(javax.activation.DataHandler) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) JMSMTOMService(org.apache.cxf.jms_mtom.JMSMTOMService) Test(org.junit.Test)

Aggregations

Closeable (java.io.Closeable)2 URL (java.net.URL)2 DataHandler (javax.activation.DataHandler)2 QName (javax.xml.namespace.QName)2 Endpoint (javax.xml.ws.Endpoint)2 JMSMTOMPortType (org.apache.cxf.jms_mtom.JMSMTOMPortType)2 Test (org.junit.Test)2 Binding (javax.xml.ws.Binding)1 BindingProvider (javax.xml.ws.BindingProvider)1 Holder (javax.xml.ws.Holder)1 SOAPBinding (javax.xml.ws.soap.SOAPBinding)1 JMSMTOMService (org.apache.cxf.jms_mtom.JMSMTOMService)1 JMSOutMTOMService (org.apache.cxf.jms_mtom.JMSOutMTOMService)1