The wsdl does not have any reference/indication that there is an
attachment. 
My operations allow the client to dictate a mime or dime encoding (a
string parameter in the requestMessage).
Sorry for the confusion.

Attachments are handled as per your description below.

The wsdl for attachments in .Net is different from the Axis wsdl (SwA as
per the spec) and neither side plays well with the other.


Raul 

-----Original Message-----
From: BLIS Webmaster (Patrick Houbaux)
[mailto:[EMAIL PROTECTED] 
Sent: Friday, January 07, 2005 1:36 PM
To: [EMAIL PROTECTED]
Subject: Re: Best way to send attachments

Do you mean you succeeded to automatically generate a WSDL with
java2wsdl containing attachment information on operations?

If yes what's the method for that, I have been asking that several time
in this mailing list but no answer so far ;)

Cheers,
Patrick.

Flores, Raul wrote:
> I don't believe there is a way to define this in wsdl so that both 
> .Net and Java(axis) can consume the wsdl. Someone please correct me if

> I am wrong. My clients just have to understand that certain methods 
> have filles attached. I also allow them to set a request parameter do 
> define whether the attachment should be set to Dime or Mime encoding 
> (the service is Axis).
> 
> 
> Raul
> 
> -----Original Message-----
> From: BLIS Webmaster (Patrick Houbaux) 
> [mailto:[EMAIL PROTECTED]
> Sent: Friday, January 07, 2005 1:12 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Best way to send attachments
> 
> I have no problem sending attachements to .NET client.
> 
> I have a RPC web service (I guess it works for other web service 
> style), and here is the methodologie:
> 
> Let's assume you have a web service supposed to send some attachments,

> the idea is to add the attachment to the SOAP message before the web 
> service method returns on the server side (please note the following 
> is using AXIS 1.1, but it is almost the same with the latest version 
> of AXIS, the AXIS API has changed a bit).
> 
> 1- get the response message from the message context:
>       //... 
>       org.apache.axis.MessageContext msgContext= 
> org.apache.axis.MessageContext.getCurrentContext();
>       org.apache.axis.Message rspMsg= msgContext.getResponseMessage();
> 
> 2 - Set the attachment type to be sent as DIME
>  
>       
> rspMsg.getAttachmentsImpl().setSendType(org.apache.axis.attachments.At
> ta
> chments.SEND_TYPE_DIME);
> 
> 3- Let's assume you want to send a file
> 
>         java.io.File fileToAddAsAttachment = new java.io.File("<the 
> path to your file>");
> 
> 4- Add the file to attachment of the response message
> 
>       javax.activation.DataHandler dh=new
> javax.activation.DataHandler(new
> javax.activation.FileDataSource(fileToAddAsAttachment));
>       org.apache.axis.attachments.AttachmentPart part = new 
> org.apache.axis.attachments.AttachmentPart(dh);
>         rspMsg.addAttachmentPart(part);
> 
> 5- Return your method
> 
> The drawback with that is I haven't figured out how to declare (with
> java2wsdl) the attachment in the WSDL so you have to document your web

> service or inform your clients they have to expect some attachments 
> when they call your method.
> 
> On the .NET client side, the method is the following:
> 
> 1- Call the web service method
> 
> 2- Just after the previous call returned, get the SOAP Response 
> message context
>       SoapContext rspContext = service.ResponseSoapContext;
> 
> 3- Get the DIME attachements, loop on them and write in a file what 
> you find there:
>         DimeAttachmentCollection attachments = rspContext.Attachments;
>       for (int i=0; i<attachments.Count; i++)
>       {
>               Stream str = attachments[i].Stream;
>               FileStream fs = new FileStream("<the file name where you
want to 
> save the attachment>",FileMode.Create,FileAccess.Write);
>               ((MemoryStream)str).WriteTo(fs);
>               str.Close();
>               fs.Close();
>       }
> 
> That's all, that works perfectly for me ... hope it helps.
> 
> Cheers,
> Patrick.
> 
> 
> 
> Vy Ho wrote:
> 
>>All of the reples make no sense whatsover to me.
>>
>>The original poster makes a very clear question that how to send 
>>attachments using soap way that works with many environments.  For 
>>example, Axis and .Net.
>>
>>To rephrase this, I would say how to create a Wsdl that works with 
>>both axis and .net.  Currently, using the DataHandler in the wsdl (or 
>>generating the wsdl from java code with DataHandler) would not work 
>>with other environment.  I haven't tried this, but looking at the 
>>definition of DataHandler (package name), and its namespace in the 
>>wsdl, you can tell it comes from apache, not some Soap standard, 
>>unless Apache is the official standard used for attachment.
>>
>>It's funny to read a bunch of replies that have little answer value to
> 
> 
>>the original question.

Reply via email to