Hi Dominik-

I found this Array of Strings example most useful for style="wrapped" and use="literal"
http://dinoch.dyndns.org:7070/axis1.2/AboutArrays2.jsp

and this considerably more comprehensive Array of Beans example useful for style="rpc" and use="encoded" with Bean defined as complexType you may want to consider creating your wsdl which generates the service and client stubs from the complexType

http://www.mail-archive.com/[EMAIL PROTECTED]/msg08934.html

HTH/
M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- From: "Dominik Pich" <[EMAIL PROTECTED]>
To: <axis-user@ws.apache.org>
Sent: Wednesday, June 06, 2007 4:00 PM
Subject: Attachments for Webservice in Eclipse using axis 1.3 on tomcat 5.5


Hi,

I am using Eclipse 3.2 with the latest Webtools to develop a webservice.
As engine to run the service I use to tomcat 5.5 with axis 1.3 (axis is coming with eclipse!? - well I havent installed it anyway :D)

IDEA:
the service exposes two operations:
<code>
BackupResult uploadFiles(BackupFile[] files);
BackupResult downloadFiles();
//result is container for error OR files array.
</code>

SERVER:
Axis was used here to make WSDL for my Java Bean and manages the service when published on the tomcat server.

CLIENT:
wsdl2java genereated me the necessary stubs for the needed Bean (and all complex types)
My calls to the service are performed using axis

SO FAR SO GOOD
All's up and running... but one major drawback: every file's content is a byte[] This works for small files or few files but not when having to load all data in memory just so I can then send it off. I decided that what I wanted were attachments. And as my clients are java and/or c# I needed a interopable solution.

AND HERE'S WHERE IT WENT WRONG
:) I realized I'd need REAL Attachments (not just some variable typed as DataHandler) and they'd have to be in the DIME format. I cant get ANY attachment to work though :/ (oh and I do have action and mail.jar - no RuntimeError IIRC)

I tackled upload first. So the client has to attach data.
<code>
//remove old and make DIME
try {
((BackupServiceProxy) backupService).getStub().clearAttachments();
((BackupServiceProxy) backupService).getStub()._setProperty(
Call.ATTACHMENT_ENCAPSULATION_FORMAT,
Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME);
} catch (Exception e) {
e.printStackTrace();
}
...
//attach File
DataSource source = new FileDataSource(new File(path));
DataHandler buildFile = new DataHandler(source);
try {
((BackupServiceProxy) backupService).getStub().addAttachment(
buildFile);

} catch (Exception e) {
e.printStackTrace();
}
</code>
I do this in a static private method after which I make the call using the proxy object (which in turn just calls the stub):
<code>
public core.BackupResult uploadFiles(core.BackupSettings settings,
core.BackupFile[] files) throws java.rmi.RemoteException {
if (backupService == null)
_initBackupServiceProxy();
     try {
int attachLength = ((BackupServiceSoapBindingStub) backupService).getAttachments().length;
    System.out.println(attachLength + " attachments");
     } catch (Exception e) {
         e.printStackTrace();
     } return backupService.uploadFiles(settings, files);
}
</code>
i added an output and it returns the correct amount of attachments namely one for each file.

next step is to 'unpack' the attachments on the server and here I get 0 everytime:
<code>
public static AttachmentPart[] getMessageAttachments() throws  AxisFault {
MessageContext msgContext = MessageContext.getCurrentContext();
if (null == msgContext) {
System.out.println("cant get context");
return null;
}

System.out.println("name of msg:" + msgContext.getCurrentMessage ().getSOAPPartAsString());
Iterator it = msgContext.getCurrentMessage().getAttachments();
ArrayList<AttachmentPart> attachments = new  ArrayList<AttachmentPart>();
while (it.hasNext()) {
AttachmentPart part = (AttachmentPart) it.next();
attachments.add(part);
}
System.out.println(attachments.size() + " attachments");
return attachments.toArray(new AttachmentPart[0]);
}
}
</code>

QUESTION:
Simply - WHY. Im desperate and after hours of experimenting I ran out of ideas...

Best regards,
and thanks in advance,
Dominik

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to