Search in sources :

Example 6 with Holder

use of javax.xml.ws.Holder in project camel by apache.

the class CxfConsumerPayloadFaultCauseEnabledTest method testInvokingFromCxfClient.

@Test
public void testInvokingFromCxfClient() throws Exception {
    this.getCamelContextService();
    URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
    PersonService ss = new PersonService(wsdlURL, SERVICE_QNAME);
    Person client = ss.getSoap();
    Client c = ClientProxy.getClient(client);
    c.getInInterceptors().add(new LoggingInInterceptor());
    c.getOutInterceptors().add(new LoggingOutInterceptor());
    ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceAddress);
    Holder<String> personId = new Holder<String>();
    personId.value = "";
    Holder<String> ssn = new Holder<String>();
    Holder<String> name = new Holder<String>();
    try {
        client.getPerson(personId, ssn, name);
        fail("SOAPFault expected!");
    } catch (Exception e) {
        assertTrue(e instanceof SOAPFaultException);
        SOAPFault fault = ((SOAPFaultException) e).getFault();
        assertEquals("Someone messed up the service. Caused by: Homer", fault.getFaultString());
    }
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) PersonService(org.apache.camel.wsdl_first.PersonService) Holder(javax.xml.ws.Holder) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPFault(javax.xml.soap.SOAPFault) Client(org.apache.cxf.endpoint.Client) Person(org.apache.camel.wsdl_first.Person) URL(java.net.URL) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 7 with Holder

use of javax.xml.ws.Holder in project camel by apache.

the class CxfConsumerPayloadFaultTest method testInvokingFromCxfClient.

@Test
public void testInvokingFromCxfClient() throws Exception {
    URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
    PersonService ss = new PersonService(wsdlURL, QName.valueOf(SERVICE_NAME));
    Person client = ss.getSoap();
    Client c = ClientProxy.getClient(client);
    c.getInInterceptors().add(new LoggingInInterceptor());
    c.getOutInterceptors().add(new LoggingOutInterceptor());
    ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceAddress);
    Holder<String> personId = new Holder<String>();
    personId.value = "";
    Holder<String> ssn = new Holder<String>();
    Holder<String> name = new Holder<String>();
    Throwable t = null;
    try {
        client.getPerson(personId, ssn, name);
        fail("expect UnknownPersonFault");
    } catch (UnknownPersonFault e) {
        t = e;
        assertEquals("Get the wrong fault detail", "", e.getFaultInfo().getPersonId());
    }
    assertNotNull(t);
    assertTrue(t instanceof UnknownPersonFault);
}
Also used : UnknownPersonFault(org.apache.camel.wsdl_first.UnknownPersonFault) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) PersonService(org.apache.camel.wsdl_first.PersonService) Holder(javax.xml.ws.Holder) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) Person(org.apache.camel.wsdl_first.Person) URL(java.net.URL) Test(org.junit.Test)

Example 8 with Holder

use of javax.xml.ws.Holder in project camel by apache.

the class CxfJavaMtomProducerPayloadTest method testInvokingService.

@SuppressWarnings("unchecked")
@Test
public void testInvokingService() throws Exception {
    if (MtomTestHelper.isAwtHeadless(null, log)) {
        return;
    }
    final Holder<byte[]> photo = new Holder<byte[]>("RequestFromCXF".getBytes("UTF-8"));
    final Holder<Image> image = new Holder<Image>(getImage("/java.jpg"));
    Exchange exchange = context.createProducerTemplate().send(MTOM_ENDPOINT_URI_MTOM_ENABLE, new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setBody(new Object[] { photo, image });
        }
    });
    // Make sure we don't put the attachement into out message
    assertEquals("The attachement size should be 0 ", 0, exchange.getOut().getAttachments().size());
    Object[] result = exchange.getOut().getBody(Object[].class);
    Holder<byte[]> photo1 = (Holder<byte[]>) result[1];
    Holder<Image> image1 = (Holder<Image>) result[2];
    assertEquals("ResponseFromCamel", new String(photo1.value, "UTF-8"));
    assertNotNull(image1.value);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Holder(javax.xml.ws.Holder) Image(java.awt.Image) Test(org.junit.Test)

Example 9 with Holder

use of javax.xml.ws.Holder in project camel by apache.

the class CxfMtomConsumerTest method testInvokingService.

@Test
public void testInvokingService() throws Exception {
    if (MtomTestHelper.isAwtHeadless(null, log)) {
        return;
    }
    Holder<byte[]> photo = new Holder<byte[]>("RequestFromCXF".getBytes("UTF-8"));
    Holder<Image> image = new Holder<Image>(getImage("/java.jpg"));
    Hello port = getPort();
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) port).getBinding();
    binding.setMTOMEnabled(true);
    port.detail(photo, image);
    assertEquals("ResponseFromCamel", new String(photo.value, "UTF-8"));
    assertNotNull(image.value);
}
Also used : Hello(org.apache.camel.cxf.mtom_feature.Hello) Holder(javax.xml.ws.Holder) SOAPBinding(javax.xml.ws.soap.SOAPBinding) Image(java.awt.Image) Test(org.junit.Test)

Example 10 with Holder

use of javax.xml.ws.Holder in project quickstarts by jboss-switchyard.

the class SoapMtomClient method sendMessage.

public static Image sendMessage(String wsdl) throws Exception {
    ImageService imageService = new ImageServiceService(new URL(wsdl)).getImageServicePort(new MTOMFeature());
    // Create the Image bytes and send it to the MTOM endpoint...
    URL fileURL = Classes.getResource("switchyard_icon.jpeg");
    File aFile = new File(new URI(fileURL.toString()));
    long fileSize = aFile.length();
    Holder<byte[]> param = new Holder<byte[]>();
    param.value = new byte[(int) fileSize];
    InputStream in = fileURL.openStream();
    int len = in.read(param.value);
    while (len < fileSize) {
        len += in.read(param.value, len, (int) (fileSize - len));
    }
    byte[] response = imageService.resizeImage(param);
    return ImageIO.read(new ByteArrayInputStream(response));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MTOMFeature(javax.xml.ws.soap.MTOMFeature) Holder(javax.xml.ws.Holder) URI(java.net.URI) URL(java.net.URL) ByteArrayInputStream(java.io.ByteArrayInputStream) File(java.io.File)

Aggregations

Holder (javax.xml.ws.Holder)129 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)77 Test (org.testng.annotations.Test)53 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)48 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)33 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)29 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)29 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)24 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)23 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 Test (org.junit.Test)23 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)19 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)18 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)16 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)15 CountDownLatch (java.util.concurrent.CountDownLatch)15 IpPort (io.servicecomb.foundation.common.net.IpPort)14 ClientException (io.servicecomb.serviceregistry.client.ClientException)14