newbie_user
16 years agoNew Contributor
Getting SOAP attachment from Java web service
I have a Java web service (Axis2 1.4.1) that is adding text data to the out going MessageContext and I want to have the document returned to SOAPUI as a SOPAUI response attachment. Currently I am not getting any attachments in SOAPUI (v. 2.5.1).
I am getting the attachment text from a BLOB column in the database as a byte[] and converting to a String data type. Then adding the text to the MessageContext. I am passing in a String to the service and returning a Java class to the client. I was able to successfully pull out the attachment from the MessageContext with a Java client bit would like to return the attachment in SOAPUI.
I also tried ConfigurableDataHandler with the content Type set to 'image/gif' and transfer encoding set to 'base64' with same results.
MessageContext inMessageContext = MessageContext.getCurrentMessageContext();
OperationContext operationContext = inMessageContext.getOperationContext();
// ---- get out going message context for attachment to be added.
MessageContext outMessageContext = operationContext
.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
String sAttachValue = new String(bytesAttach);
DataHandler attachDataHandler = new DataHandler(sAttachValue, "text/plain");
String graphImageID = outMessageContext.addAttachment(dataHandler);
Any assistance would be appreciated.
I am getting the attachment text from a BLOB column in the database as a byte[] and converting to a String data type. Then adding the text to the MessageContext. I am passing in a String to the service and returning a Java class to the client. I was able to successfully pull out the attachment from the MessageContext with a Java client bit would like to return the attachment in SOAPUI.
I also tried ConfigurableDataHandler with the content Type set to 'image/gif' and transfer encoding set to 'base64' with same results.
MessageContext inMessageContext = MessageContext.getCurrentMessageContext();
OperationContext operationContext = inMessageContext.getOperationContext();
// ---- get out going message context for attachment to be added.
MessageContext outMessageContext = operationContext
.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
String sAttachValue = new String(bytesAttach);
DataHandler attachDataHandler = new DataHandler(sAttachValue, "text/plain");
String graphImageID = outMessageContext.addAttachment(dataHandler);
Any assistance would be appreciated.