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());
}
}
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);
}
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);
}
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);
}
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));
}
Aggregations