Hi, > > I was successfully able to write an independent web service with a client > to test where the attachments' file name is passed as parameter in the web > service method. > > Based on the lines of > http://thilinag.blogspot.com/2008/04/download-file-from-axis2-web-service.html > Hope what u meant is that you were able to retrieve the content of the file in the server side. Did u had a look at the MTOM sample that comes with Axis2? Axis2 MTOM sample uploads a file to a webservice using a WSDL generated client and a service.
> My requirement in real world is that my web service may or may not have the > attachments [0 or many attachments]. > > And my web service method should be able to support all the scenarios > > There are obvious two ways of doing it: > > > > - Add the array of attachment filenames in the webservice method > signature and send it using MTOM (based on the arcticle above ) > - Or send the attachments internal to soap message using data handlers > using SwA (Can we do the same thing and say enableMTOM=true?) based on this > article > > Attachments go externally when SwA is used. No..you can't mix SwA and MTOM.. Looks like you are somehow confused with the filenames vs file content... I would suggest you to use MTOM, unless there is a requirement to support legacy web service clients (eg: axis 1.x).. First look at the MTOM sample and get it to working. Focus on getting the attachment content right.. When you can get the attachments to the service, getting file names is a piece of cake. Then you can modify the WSDL given with the sample to make it support an array of optional elements containing attachments.. Adding max/minoccurs to the following element and wraping it using another parent element will do the trick. <xsd:element name="AttachmentRequest" type="tns:AttachmentType" minOccurs="0" maxOccurs="unbounded" /> Then you can code generate to your modified WSDL to write your new service and client. You can use MTOM sample client & service as references. You may also look at http://ws.apache.org/axis2/1_4_1/mtom-guide.html to get an idea about Axis2 attachments.. Please use a http sniffer like tcpmon (ws.apache.org/commons/tcpmon) to trace your messages and to verify whether the attachments are there in the message. thanks, Thilina > > - > > http://wso2.org/library/1148 > > > > *When using method 1*, how do we handle the array of Strings to send to > the client, I want to use handwritten client so I am using > > OMElement fileNamesArray = BeanUtil.getOMElement(new > QName(omNs.getNamespaceURI(),"attchFileNames"), filenames, null, false, > null); > > > > But this does not get me the datasource for the file in the webservice. > > > > *When using method 2* and I access the datahandler from messageContext > obtained using getCurrentMessageContext, my data handlers are empty. > > > > So I am not able to achieve the solution to transfer the file from client > to webservice by either of the ways. > > > > Help is really appreciated as I am completely stuck! > > > > Thanks in advance, > > Asmita > -- Thilina Gunarathne - http://thilinag.blogspot.com
