Matthias
i would suggest editting mtom-user-guide to demonstrate actual usage for
axis2-1.4.1 specifically
public class SwA {
private OperationContext operationContext;
public SwA() {
}
public void setOperationContext(OperationContext oc) throws AxisFault {
operationContext = oc;
}
public void uploadAttachment(OMElement omEle) throws AxisFault {
OMElement child = (OMElement) omEle.getFirstOMChild();
OMAttribute attr = child.getAttribute(new QName("href"));
//Content ID processing
String contentID = attr.getAttributeValue();
contentID = contentID.trim();
if (contentID.substring(0, 3).equalsIgnoreCase("cid")) {
contentID = contentID.substring(4);
}
//contentId of cid is assumed
Attachments attachment = (Attachments)
(operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)).getAttachmentMap();
// DataHandler dataHandler = attachment.getDataHandler(contentID);
java.util.Iterator iter;
try
{
iter=attachment.getAttachments().iterator();
}
catch(AxisFault axis_fault)
{
log.debug("AxisFault produced for
attachment.getAttachments().iterator()");
}
String[] attachmentIDs;
int attachementCtr=0;
while(iter.hasNext()
{
attachmentIDs[attachmentCtr++]= iter.next();
}
}
}
public static final java.lang.String
ATTACHMENT_ENCAPSULATION_FORMAT_DIME
"axis.attachment.style.dime"
public static final java.lang.String
ATTACHMENT_ENCAPSULATION_FORMAT_MIME
"axis.attachment.style.mime"
public static final java.lang.String
ATTACHMENT_ENCAPSULATION_FORMAT_MTOM
"axis.attachment.style.mtom"
this only covers attachment style of 'mtom'
would need to refactor for both mime and dime attachment styles
suggestions?
Martin Gainty
______________________________________________
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung/Note de
déni et de confidentialité
This message is confidential. If you should not be the intended receiver, then
we ask politely to report. Each unauthorized forwarding or manufacturing of a
copy is inadmissible. This message serves only for the exchange of information
and has no legal binding effect. Due to the easy manipulation of emails we
cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung.
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est
interdite. Ce message sert à l'information seulement et n'aura pas n'importe
quel effet légalement obligatoire. Étant donné que les email peuvent facilement
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité
pour le contenu fourni.
Subject: AW: Receiving swa attachments
Date: Thu, 14 May 2009 09:24:31 +0200
From: [email protected]
To: [email protected]
Hi Chinmoy,
thanks for your answer. It gave me a hint into the right
direction. Now it is working.
Yes, I did enable the SwA property, but it is only necessary to enable
it on the client side, not on the server side as other tutorials mention as
well.
My problem was that I tried to get the content ids via the
getContentIDList() method. This method only returns the content ids which have
been parsed already. If I take the method you mention getAllContentIDs() or
getContentIDSet(), then Axis parses the other attachments and returns a
complete list of the content ids.
@Axis2-Team: Please reflect this behavior in the javadoc that only
the parsed content ids are returned by the getContentIDList().
Maybe I can help some other people with the same problem. J
Matthias.
Von: Chinmoy
Chakraborty [mailto:[email protected]]
Gesendet: Mittwoch, 13. Mai 2009 17:43
An: [email protected]
Betreff: Re: Receiving swa
attachments
Hi Matthias,
You need to set 'enableSwA'
property to true in client and server side in order to work with SwA. I am
assuming that you have done this. I tried with Axis2 1.4 and it works fine. You
can try following code sample while receving the SwA attachment in the client
side:
...............................
mepClient.execute(true);
MessageContext response =
mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
Attachments attachments =
response.getAttachmentMap();
if (attachments == null) {
return "No
attachment";
}
String[] attachmentIDs = attachments.getAllContentIDs();
for(int i = 0; i < attachmentIDs.length;
i++){
if(!attachments.getSOAPPartContentID().equals(attachmentIDs[i])){
return attachments.getDataHandler(attachmentIDs[i]);
}
}
Chinmoy
On Wed, May 13, 2009 at 8:15 PM,
<[email protected]>
wrote:
Hi group,
I am getting a bit frustrated
with swa attachments. For reason of compatibility I have to support them. I am
trying to upload a file with swa to a service. I can see via tcpmon that my
file is being sent, but on the server side I can’t see the file in the
attachments map. It is just not there. I have compared my coe with the swa
example and also changed the swa example with my code, but I had no success.
The code on the server side
looks like this:
MessageContext mctx = MessageContext.getCurrentMessageContext();
Attachments attachs =
mctx.getAttachmentMap();
List<String> cids =
attachs.getContentIDList();
String soapCid =
attachs.getSOAPPartContentID();
String url = "not
stored";
for (String cid :
cids) {
if
(!cid.equals(soapCid)) {
url = writeAttachmentToDisk(mctx.getAttachment(cid), cid);
}
}
I filter out the soap part which
is also listed in the attachments, but the list cids always only contains the
soapPartContentID.
In the articles on ws02 they
always mention that you don’t have to specify a special option to receive
swa attachments. I am probably missing sth. out. Can anybody help me here?
Thanks in advance,
Matthias.
_________________________________________________________________
Hotmail® goes with you.
http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009