hello list,
please help? what do i need to do to get at the attachments sent to my
standalone saaj-based service impl?
i'm using the Axis2-1.4/AXIOM-1.2.7 implementation of the SAAJ API in my web
service implementation class. the svc impl is deployed in oracle's oc4j
10.1.2 on a windows xp machine with sun's j2sdk1.4.2. my saaj-based svc
impl class constructs a javax.xml.soap.SOAPMessage using the InputStream and
the javax.xml.soap.MimeHeaders of the request passed in from a servlet that
first receives all incoming requests to the web app.
the MimeHeaders obj (see attached) is a newly instantiated obj, populated
with MimeHeaders.addHeader() and all the names and values of the original
mime headers obtained from HttpRequest.getHeaderNames() &
HttpRequest.getHeader();
the SOAP request sent from the client contains an attachment. using the saaj
api, i can successfully get at the javax.xml.soap.SOAPEnvelope, serialize it
(using axiom/stax) and process the raw soap env xml as required by my app.
using tcpmon, i can see that the attachment is being sent as expected from
my test client (axis2's own
$AXIS2_HOME/samples/soapwithattachments/src/sample/soapwithattachments/client/SWAClient.java,
in fact).
my problem is: SOAPMessage.countAttachments() returns 0; and
SOAPMessage.getAttachments() returns an empty iterator.
an interesting clue is: both MimeHeaders.getAllHeaders() and
javax.xml.soap.SOAPPart.getAllMimeHeaders() _unexpectedly_ return the exact
same mime headers. when i expected MimeHeaders.getAllHeaders() to return the
headers for the SOAP request and SOAPPart.getAllMimeHeaders() to return the
headers for the attachments (two distinctly different sets of mime headers).
i hope this doesn't confuse the issue, but i've established that the jwswp
saaj impl does correctly return 2 different sets of mime headers; on the
other hand, the jwsdp's javax.xml.soap.SOAPPart.getEnvelope() returns a null
SOAPEnvelope.
please, help? what have i missed? see attached for more details. thanks in
advance for your help.
// the http post request (with attachment) from the client:
POST /communication/gateway HTTP/1.1
Content-Type: multipart/related;
boundary=MIMEBoundaryurn_uuid_16EEB4EC61D6A5FBA61217169818990; type="text/xml";
start="<0.urn:uuid:[EMAIL PROTECTED]>"
SOAPAction: "urn:uploadFile"
User-Agent: Axis2
Host: localhost:8888
Transfer-Encoding: chunked
22f0
--MIMEBoundaryurn_uuid_16EEB4EC61D6A5FBA61217169818990
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <0.urn:uuid:[EMAIL PROTECTED]>
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<swa:uploadFile
xmlns:swa="http://service.soapwithattachments.sample">
<swa:name>keytool_ebook.zip</swa:name>
<swa:attchmentID>urn:uuid:16EEB4EC61D6A5FBA61217169818707</swa:attchmentID>
</swa:uploadFile>
</soapenv:Body>
</soapenv:Envelope>--MIMEBoundaryurn_uuid_16EEB4EC61D6A5FBA61217169818990Content-Type:
application/octet-streamContent-Transfer-Encoding: binaryContent-ID:
<urn:uuid:16EEB4EC61D6A5FBA61217169818707>PK..<?O?????My?
?i?*.???d]ka??.?$??????#?.'G???1???V?.???9?^.??8?eh?b?k?Kc???i?..y?'f#??P??..?5?;6??5???n^?6U??R?S??
<U?#W?.??F7f?.?y?.??fI?L?yF.fc??.*b..??L??= ?.?.?N?.?.?
===============================================
// get mime headers
...
Enumeration enumeration = httpservletrequest.getHeaderNames();
MimeHeaders mimeheaders = new MimeHeaders();
while (enumeration.hasMoreElements()) {
String s = (String) enumeration.nextElement();
String s1 = httpservletrequest.getHeader(s);
for (StringTokenizer stringtokenizer = new
StringTokenizer(s1, ","); stringtokenizer.hasMoreTokens(); mimeheaders
.addHeader(s,
stringtokenizer.nextToken().trim()))
;
}
...
===============================================
// try to get at the mime headers & attachments sent in the above http post
...
SOAPMessage soapMsg =
SOAP_MSG_FACTORY.createMessage(mimeHdrs, instrm);
SOAPPart soapPart = soapMsg.getSOAPPart();
if (soapMsg.saveRequired() ){
soapMsg.saveChanges();
}
for (Iterator i = mimeHdrs.getAllHeaders();
i.hasNext();) {
MimeHeader header = (MimeHeader) i.next();
String name = header.getName();
String value = header.getValue();
log4jLogger.debug("received " + name + "
SOAPMessage MimeHeader: " + value);
} // end for
for ( Iterator i =
soapPart.getAllMimeHeaders(); i.hasNext(); ){
MimeHeader header = (MimeHeader)
i.next();
String name = header.getName();
String value = header.getValue();
log4jLogger.debug("received " + name +
" SOAPPart MimeHeader: " + value);
}
SOAPEnvelope soapEnv = soapPart.getEnvelope();
StringWriter sw = new StringWriter();
AXIOMHelper.serialize((OMNode)soapEnv, sw, true, false);
message = sw.toString();
java.util.Iterator iterator = soapMsg.getAttachments();
log4jLogger.debug("found " + soapMsg.countAttachments()
+ " attachments ");
while (iterator.hasNext()) {
AttachmentPart attachment = (AttachmentPart)
iterator.next();
String id = attachment.getContentId();
String type = attachment.getContentType();
log4jLogger.debug("Attachment " + id + " has
content type " + type);
if (type == "text/plain") {
Object content =
attachment.getContent();
log4jLogger.debug("Attachment " +
"contains:\n" + content);
}
}
...
===============================================
// debug log output from above code snippet
DEBUG - received CONTENT-TYPE SOAPMessage MimeHeader: multipart/related;
boundary=MIMEBoundaryurn_uuid_16EEB4EC61D6A5FBA61217169818990; type="text/xml";
start="<0.urn:uuid:[EMAIL PROTECTED]>"
DEBUG - received SOAPACTION SOAPMessage MimeHeader: "urn:uploadFile"
DEBUG - received USER-AGENT SOAPMessage MimeHeader: Axis2
DEBUG - received TRANSFER-ENCODING SOAPMessage MimeHeader: chunked
DEBUG - received HOST SOAPMessage MimeHeader: localhost:8888
DEBUG - received CONTENT-TYPE SOAPPart MimeHeader: multipart/related;
boundary=MIMEBoundaryurn_uuid_16EEB4EC61D6A5FBA61217169818990; type="text/xml";
start="<0.urn:uuid:[EMAIL PROTECTED]>"
DEBUG - received SOAPACTION SOAPPart MimeHeader: "urn:uploadFile"
DEBUG - received USER-AGENT SOAPPart MimeHeader: Axis2
DEBUG - received TRANSFER-ENCODING SOAPPart MimeHeader: chunked
DEBUG - received HOST SOAPPart MimeHeader: localhost:8888
...
DEBUG - found 0 attachments
...
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]