use of org.apache.axis2.jaxws.sample.mtom1.ImageDepot in project axis-axis2-java-core by apache.
the class MtomSampleMTOMDisable2Service method sendImage.
public ImageDepot sendImage(ImageDepot input) {
TestLogger.logger.debug("MtomSampleMTOMDisable2Service [new sendImage request received]");
DataHandler data = input.getImageData();
TestLogger.logger.debug("[contentType] " + data.getContentType());
ImageDepot output = (new ObjectFactory()).createImageDepot();
Image image = null;
resetAttachmentUnmarshallingMonitor();
try {
InputStream stream = (InputStream) data.getContent();
image = ImageIO.read(stream);
DataSource imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
DataHandler handler = new DataHandler(imageDS);
output.setImageData(handler);
} catch (Exception e) {
throw new WebServiceException(e);
}
return output;
}
use of org.apache.axis2.jaxws.sample.mtom1.ImageDepot in project axis-axis2-java-core by apache.
the class MtomSampleMTOMDisableService method sendImage.
public ImageDepot sendImage(ImageDepot input) {
TestLogger.logger.debug("MtomSampleMTOMDisableService [new sendImage request received]");
DataHandler data = input.getImageData();
TestLogger.logger.debug("[contentType] " + data.getContentType());
ImageDepot output = (new ObjectFactory()).createImageDepot();
Image image = null;
resetAttachmentUnmarshallingMonitor();
try {
InputStream stream = (InputStream) data.getContent();
image = ImageIO.read(stream);
DataSource imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
DataHandler handler = new DataHandler(imageDS);
output.setImageData(handler);
} catch (Exception e) {
throw new WebServiceException(e);
}
return output;
}
use of org.apache.axis2.jaxws.sample.mtom1.ImageDepot in project axis-axis2-java-core by apache.
the class MtomSampleMTOMEnableService method sendImage.
public ImageDepot sendImage(ImageDepot input) {
TestLogger.logger.debug("MtomSampleMTOMEnableService [new sendImage request received]");
DataHandler data = input.getImageData();
TestLogger.logger.debug("[contentType] " + data.getContentType());
ImageDepot output = (new ObjectFactory()).createImageDepot();
Image image = null;
resetAttachmentUnmarshallingMonitor();
try {
InputStream stream = (InputStream) data.getContent();
image = ImageIO.read(stream);
DataSource imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
DataHandler handler = new DataHandler(imageDS);
output.setImageData(handler);
} catch (Exception e) {
throw new WebServiceException(e);
}
return output;
}
use of org.apache.axis2.jaxws.sample.mtom1.ImageDepot in project axis-axis2-java-core by apache.
the class MtomSampleMTOMThresholdService method sendImage.
public ImageDepot sendImage(ImageDepot input) {
TestLogger.logger.debug("MtomSampleMTOMEnableService [new sendImage request received]");
DataHandler data = input.getImageData();
TestLogger.logger.debug("[contentType] " + data.getContentType());
ImageDepot output = (new ObjectFactory()).createImageDepot();
Image image = null;
resetAttachmentUnmarshallingMonitor();
try {
InputStream stream = (InputStream) data.getContent();
image = ImageIO.read(stream);
DataSource imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
DataHandler handler = new DataHandler(imageDS);
output.setImageData(handler);
} catch (Exception e) {
throw new WebServiceException(e);
}
return output;
}
use of org.apache.axis2.jaxws.sample.mtom1.ImageDepot in project axis-axis2-java-core by apache.
the class SampleMTOMTests method testMtomWithProxy.
/**
* Tests sending an image with MTOM, using a JAX-WS Dynamic Proxy.
*
* @param result - String - used to pass back results to servlet.
* @return String - the input string or null
* @throws Exception
*/
public String testMtomWithProxy(String result, URL url) throws Exception {
ImageDepot response;
System.out.println(">>---------------------------------------");
System.out.println(">>MTOM Proxy Test");
init();
// Set the data inside of the appropriate object
ImageDepot imageDepot = new ObjectFactory().createImageDepot();
imageDepot.setImageData(content);
if (null != result) {
result = result.concat("Invoking MTOM proxy with a binary payload\n");
} else {
System.out.println(">>MTOM Invoking proxy with a binary payload");
}
// Setup the necessary JAX-WS artifacts
try {
if (soap12) {
// Use the generated proxy
MtomSample12PortProxy proxy = new MtomSample12PortProxy(url);
proxy._getDescriptor().setEndpoint(uriString + urlSuffix);
// Enable MTOM
BindingProvider bp = (BindingProvider) proxy._getDescriptor().getProxy();
SOAPBinding binding = (SOAPBinding) bp.getBinding();
binding.setMTOMEnabled(true);
// Send the image and process the response image
response = proxy.sendImage(imageDepot);
} else {
// SOAP 1.1 Create the service
// Use the generated proxy
MtomSamplePortProxy proxy = new MtomSamplePortProxy(url);
proxy._getDescriptor().setEndpoint(uriString + urlSuffix);
// Enable MTOM
BindingProvider bp = (BindingProvider) proxy._getDescriptor().getProxy();
SOAPBinding binding = (SOAPBinding) bp.getBinding();
binding.setMTOMEnabled(true);
// Send the image and process the response image
response = proxy.sendImage(imageDepot);
}
if (null != result) {
if (response != null) {
result = result.concat("MTOM Proxy Response received - " + response.getImageData().getContentType());
} else {
result = result.concat("ERROR: MTOM Proxy NULL Response received\n");
}
} else {
if (response != null) {
System.out.println(">>MTOM Response received");
System.out.println(">>MTOM Writing returned image to proxy_response.gif");
processImageDepot(response, "proxy_response.gif");
} else {
System.out.println(">> [ERROR] - Response from the server was NULL");
}
}
} catch (Exception e) {
if (null != result) {
result = result.concat(">> [ERROR] - Exception making connection.");
}
System.out.println(">> [ERROR] - Exception making connection.");
e.printStackTrace();
}
System.out.println(">>MTOM Proxy Done");
return (result);
}
Aggregations