I use TCP monitor to view the contents on the wire. They seems correct.
I have attached both the server and the client programs.
Could anyone help me with the problem?
Regards,
Xinjun
On 6/12/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:
Hi,
I have a web service receives attachment file from clients and sends
attachment file to clients. Previously it assume AttachmentMap only contains
attachment files and SOAP message is excluded. When I use XML Exchanger Lite
as client to invoke the web service, the attachment is received by the
server properly, and the acknowledgement file is returned to the client
properly.
Now I use Axis2 client (OperationClient) to program the client. My
observation shows that when I list AttachmentMap, the SOAP message is now
the first attachment, and the actual attachment becomes the second
attachment. The server is simply take the first attachment and do the
processing. Effectively after I switching to Axis2 client, the server now is
treating the SOAP message as the attachment which causes error.
Why does SOAP message goes into the AttachmentMap? Is this a bug or a
desirable change?
Regards,
Xinjun
// receive the file submitted from the client
Attachments attachments = in.getAttachmentMap(); // in
is request MessageContext
String[] contentIDs = attachments.getAllContentIDs();
String contentID = contentIDs[0];
DataHandler dataHandler = in.getAttachment(contentID);
String fileFullPath =
createFullManifestFilePullPath(submissionFileName);
FileOutputStream fos = new FileOutputStream(fileFullPath);
dataHandler.writeTo(fos);
// now attach the acknowledgement file
String ackFileName = new File(ackFullPath).getName();
FileDataSource ackDataSource = new FileDataSource(ackFullPath);
DataHandler outDataHandler = new DataHandler(ackDataSource);
String attachmentID = out.addAttachment(outDataHandler);
out.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_SWA,
org.apache.axis2.Constants.VALUE_TRUE);
EndpointReference epr = new EndpointReference(url);
ServiceClient serviceClient = new ServiceClient();
Options options = new Options();
serviceClient.setOptions(options);
options.setTo(epr);
options.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_SWA,
org.apache.axis2.Constants.VALUE_TRUE);
options.setProperty(org.apache.axis2.Constants.Configuration.SEND_STACKTRACE_DETAILS_WITH_FAULTS,
org.apache.axis2.Constants.VALUE_TRUE);
options.setProperty(org.apache.axis2.Constants.Configuration.CACHE_ATTACHMENTS,
org.apache.axis2.Constants.VALUE_TRUE);
options.setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION,
HTTPConstants.HEADER_PROTOCOL_10);
options.setProperty(HTTPConstants.CHUNKED,
org.apache.axis2.Constants.VALUE_FALSE);
options.setProperty(org.apache.axis2.Constants.Configuration.ATTACHMENT_TEMP_DIR,
"D:/impl/ace/temp");
options.setProperty(org.apache.axis2.Constants.Configuration.FILE_SIZE_THRESHOLD,
"4000");
MessageContext inMsgCtx = new MessageContext();
inMsgCtx.setSoapAction(soapAction);
inMsgCtx.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_SWA,
org.apache.axis2.Constants.VALUE_TRUE);
SOAPEnvelope inEnv = null;
InputStream reqStream = new
FileInputStream(soapReqFilePath);
Document inDoc =
Utils.getDocumentFromInputStream(reqStream);
inEnv = Axis2Util.getSOAPEnvelopeFromDocument(inDoc,
Constants.SOAP11_NS);
inMsgCtx.setEnvelope(inEnv);
DataSource ds = new FileDataSource(attachFilePath);
DataHandler inDH = new DataHandler(ds);
String contentID = inMsgCtx.addAttachment(inDH);
System.out.println(contentID);
operationClient =
serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
operationClient.addMessageContext(inMsgCtx);
operationClient.execute(true);
MessageContext resMsgCtx =
operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
resMsgCtx.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_SWA,
org.apache.axis2.Constants.VALUE_TRUE);
SOAPEnvelope resEnv = resMsgCtx.getEnvelope();
System.out.println("SOAPResponse: \n" +
resEnv.toString());
Attachments attachments = resMsgCtx.getAttachmentMap();
String[] contentIDs = attachments.getAllContentIDs();
System.out.println("contentIDs.length=" +
contentIDs.length);
for(int i = 0; i < contentIDs.length; i++) {
System.out.println("contentIDs[" + i + "] = " +
contentIDs[i]);
DataHandler outDH =
attachments.getDataHandler(contentIDs[i]);
DataSource fds = outDH.getDataSource();
InputStream outAttachIS = fds.getInputStream();
System.out.println("Attachments[" + i + "]: \n"
+ Utils.inputStreamToString(outAttachIS));
}---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]