Re: Attachments - AXIS Server, .NET Client
Hi, John, Could you please share your C# client code with us since the reference is so hard to find on this topic in the .NET society? I am writing a C# client to send an attachment to an Axis server. Thanks, Scott [John Walker wrote] Do you mean the .NET client side? I have created a similar C# class for that portion. The C# class has the ability to add attachments for a client, and to detach them. As for a Java client, I have only created a method that solves half of the problem. I think, though, after solving the first half, the second half should be a trivial thing to create. I will see if I can make something to contribute next week. Regards, John Walker
Re: Attachments - AXIS Server, .NET Client
Hi, 1) What level of support currently there is inAXIS 1.2 for message attachments. E.g., does it support both DIME and and SwA? 2) WS-I has SOAP attachment profile finalized in August 2004. Does AXIS support SOAP attachment profile: http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html 3) It seems the W3C's end goal is to support MTOM approach of transfering binary attachments to SOAP messages, but it seems that this may take some time. In any case MTOM should in theory be compatible with SOAP attachment profile from MIME perspective. Also, MTOM is only compatible with SOAP 1.2 and WSDL 1.2 while AXIS 1.2 supports both SOAP 1.1/1.2 and WSDL 1.1. 4) So, really, it seems that commercially from the standpoint of SOAP attachment interoperability WS-I Attachment Profile (as mentioned in #2) is the only option. However, I am wondering how can you support DIME from WSE 2.0? Is not DIME on supported in WSE 1.0? John Walker [EMAIL PROTECTED] wrote: Do you mean the .NET client side? I have created a similar C# classfor that portion. The C# class has the ability to add attachments fora client, and to detach them.As for a Java client, I have only created a method that solves half ofthe problem. I think, though, after solving the first half, thesecond half should be a trivial thing to create. I will see if I canmake something to contribute next week.Regards,John Walker On Wed, 24 Nov 2004 12:54:53 -0600, Rahul Tripathi <[EMAIL PROTECTED]>wrote: Is there a way to provide similar functionality on the client side? Using the MessageContext does not work unless one adds a Handler on the client. On Tue, 23 Nov 2004 12:04:15 -0800, John Walker <[EMAIL PROTECTED]>wrote:I have a spot of code I would like to contribute to the group. This class I developed can be used to detach or attach any file sent over web services. This class is intended for use on the server side, and will need just a little massaging to work in your environment. It took me several painstaking hours to get AXIS to send an attachment to a requesting .NET client, and for .NET to send an attachment to a listening AXIS server. With the help of the Steve Loughran article "Fear of Attachments", and not a little of his code (thanks Steve!), I was able to get .NET clients to utilize files stored on my AXIS web server. Please forgive the Exception handling. To read Steve Loughran's article I referred to, ref: http://www.mail-archive.com/axis-user@xml.apache.org/msg08732.html - John Walker Do you Yahoo!? The all-new My Yahoo! Get yours free!
Re: Attachments - AXIS Server, .NET Client
Do you mean the .NET client side? I have created a similar C# class for that portion. The C# class has the ability to add attachments for a client, and to detach them. As for a Java client, I have only created a method that solves half of the problem. I think, though, after solving the first half, the second half should be a trivial thing to create. I will see if I can make something to contribute next week. Regards, John Walker On Wed, 24 Nov 2004 12:54:53 -0600, Rahul Tripathi [EMAIL PROTECTED] wrote: Is there a way to provide similar functionality on the client side? Using the MessageContext does not work unless one adds a Handler on the client. On Tue, 23 Nov 2004 12:04:15 -0800, John Walker [EMAIL PROTECTED] wrote: I have a spot of code I would like to contribute to the group. This class I developed can be used to detach or attach any file sent over web services. This class is intended for use on the server side, and will need just a little massaging to work in your environment. It took me several painstaking hours to get AXIS to send an attachment to a requesting .NET client, and for .NET to send an attachment to a listening AXIS server. With the help of the Steve Loughran article Fear of Attachments, and not a little of his code (thanks Steve!), I was able to get .NET clients to utilize files stored on my AXIS web server. Please forgive the Exception handling. To read Steve Loughran's article I referred to, ref: http://www.mail-archive.com/axis-user@xml.apache.org/msg08732.html - John Walker
Re: Attachments - AXIS Server, .NET Client
Thanks for the contribution! John Walker wrote: I have a spot of code I would like to contribute to the group. This class I developed can be used to detach or attach any file sent over web services. This class is intended for use on the server side, and will need just a little massaging to work in your environment. It took me several painstaking hours to get AXIS to send an attachment to a requesting .NET client, and for .NET to send an attachment to a listening AXIS server. With the help of the Steve Loughran article "Fear of Attachments", and not a little of his code (thanks Steve!), I was able to get .NET clients to utilize files stored on my AXIS web server. Please forgive the Exception handling. To read Steve Loughran's article I referred to, ref: http://www.mail-archive.com/axis-user@xml.apache.org/msg08732.html - John Walker package ws.attachments; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Iterator; import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.xml.soap.AttachmentPart; import org.apache.axis.AxisFault; import org.apache.axis.Message; import org.apache.axis.MessageContext; import org.apache.axis.attachments.Attachments; import org.apache.axis.attachments.AttachmentsImpl; import org.apache.log4j.Logger; /** * This class can be used from within any AXIS web service method * * @author jwalker */ public class AttachmentTrundler { private static final Logger _logger = Logger.getLogger(AttachmentTrundler.class); public AttachmentTrundler() { } /** * Attaches the file to the outgoing response message as DIME attachment. * This attachment should be consumable by all .NET web service * clients. The clients we are using are auto-generated proxy classes * that have no knowledge of the attachment coming. The WSDL will not * contain this information. * * @param fileName The full name of the file on the local filesystem to * send to the client requesting file attachment * @return true, indicating attachment was successful. * * @throws AttachmentException */ public boolean attachFile(File file) throws AttachmentException { try { MessageContext msgContext = MessageContext.getCurrentContext(); Message resMsg = msgContext.getResponseMessage(); //Get the file from the filesystem FileDataSource fileDS = new FileDataSource(file); DataHandler handler = new DataHandler(fileDS); //Create the attachment as a DIME attachment AttachmentPart attachment = resMsg.createAttachmentPart(); resMsg.getAttachmentsImpl().setSendType(AttachmentsImpl.SEND_TYPE_DIME); attachment.setDataHandler(handler); //You can set the content type to be anything you wish. All my files are zips attachment.setContentType("zip"); resMsg.addAttachmentPart(attachment); }catch (Exception e) { //I know some will argue about the wisdom of catching Exception, and then // throwing AttachmentException, and they would probably be right. _logger.error("attachFile(File file = " + file + ")", e); throw new AttachmentException("There was a problem attaching the file to the web service call", e); } return true; } /** * This method receives the DIME encoded attachment from the client and * saves it on the server. * * @param filename as the name to save the file on the server * @return a java.io.File that represents the object on the file system * * @throws AttachmentException This exception is thrown if anything * goes wrong within the detachment process. */ public File detachFile(String filename) throws AttachmentException { InputStream is = null; FileOutputStream os = null; File file = null; int totalAttachments ; try { //Get all the attachments AttachmentPart[] attachments = getMessageAttachments(); /* * getMessageAttachments() as provided by Steve Loughran in his mail * to axis-user group * http://www.mail-archive.com/axis-user@xml.apache.org/msg08732.html */ //Put the logic in a loop for totalAttachments for multiple // attachments. totalAttachments = attachments.length; _logger.debug("saveFile(String filename = " + filename + ") - " + "Total Attachments Received Are: "+ totalAttachments); if (totalAttachments != 1) { throw new AttachmentException("Too many attachments sent [" + attachments.length + "] Please limit to 1"); } //Extract the first attachment. (Since in this case we have only one attachment sent) DataHandler dh = attachments[0].getDataHandler(); //Extract the file name of the first attachment. String name = filename; _logger.debug("saveFile(String filename = " + filename + ") - File received on server is: " + name); //Get the streams to file and from attachment, then stream to disk is = dh.getInputStream();
Re: Attachments - AXIS Server, .NET Client
Is there a way to provide similar functionality on the client side? Using the MessageContext does not work unless one adds a Handler on the client. On Tue, 23 Nov 2004 12:04:15 -0800, John Walker [EMAIL PROTECTED] wrote: I have a spot of code I would like to contribute to the group. This class I developed can be used to detach or attach any file sent over web services. This class is intended for use on the server side, and will need just a little massaging to work in your environment. It took me several painstaking hours to get AXIS to send an attachment to a requesting .NET client, and for .NET to send an attachment to a listening AXIS server. With the help of the Steve Loughran article Fear of Attachments, and not a little of his code (thanks Steve!), I was able to get .NET clients to utilize files stored on my AXIS web server. Please forgive the Exception handling. To read Steve Loughran's article I referred to, ref: http://www.mail-archive.com/axis-user@xml.apache.org/msg08732.html - John Walker
Attachments - AXIS Server, .NET Client
I have a spot of code I would like to contribute to the group. This class I developed can be used to detach or attach any file sent over web services. This class is intended for use on the server side, and will need just a little massaging to work in your environment. It took me several painstaking hours to get AXIS to send an attachment to a requesting .NET client, and for .NET to send an attachment to a listening AXIS server. With the help of the Steve Loughran article Fear of Attachments, and not a little of his code (thanks Steve!), I was able to get .NET clients to utilize files stored on my AXIS web server. Please forgive the Exception handling. To read Steve Loughran's article I referred to, ref: http://www.mail-archive.com/axis-user@xml.apache.org/msg08732.html Regards, John Walker johnwalker00 at gmail dot com package ws.attachments; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Iterator; import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.xml.soap.AttachmentPart; import org.apache.axis.AxisFault; import org.apache.axis.Message; import org.apache.axis.MessageContext; import org.apache.axis.attachments.Attachments; import org.apache.axis.attachments.AttachmentsImpl; import org.apache.log4j.Logger; /** * This class can be used from within any AXIS web service method * * @author jwalker */ public class AttachmentTrundler { private static final Logger _logger = Logger.getLogger(AttachmentTrundler.class); public AttachmentTrundler() { } /** * Attaches the file to the outgoing response message as DIME attachment. * This attachment should be consumable by all .NET web service * clients. The clients we are using are auto-generated proxy classes * that have no knowledge of the attachment coming. The WSDL will not * contain this information. * * @param fileName The full name of the file on the local filesystem to * send to the client requesting file attachment * @return true, indicating attachment was successful. * * @throws AttachmentException */ public boolean attachFile(File file) throws AttachmentException { try { MessageContext msgContext = MessageContext.getCurrentContext(); Message resMsg = msgContext.getResponseMessage(); //Get the file from the filesystem FileDataSource fileDS = new FileDataSource(file); DataHandler handler = new DataHandler(fileDS); //Create the attachment as a DIME attachment AttachmentPart attachment = resMsg.createAttachmentPart(); resMsg.getAttachmentsImpl().setSendType(AttachmentsImpl.SEND_TYPE_DIME); attachment.setDataHandler(handler); //You can set the content type to be anything you wish. All my files are zips attachment.setContentType(zip); resMsg.addAttachmentPart(attachment); }catch (Exception e) { //I know some will argue about the wisdom of catching Exception, and then // throwing AttachmentException, and they would probably be right. _logger.error(attachFile(File file = + file + ), e); throw new AttachmentException(There was a problem attaching the file to the web service call, e); } return true; } /** * This method receives the DIME encoded attachment from the client and * saves it on the server. * * @param filename as the name to save the file on the server * @return a java.io.File that represents the object on the file system * * @throws AttachmentException This exception is thrown if anything * goes wrong within the detachment process. */ public File detachFile(String filename) throws AttachmentException { InputStream is = null; FileOutputStream os = null; File file = null; int totalAttachments ; try { //Get all the attachments AttachmentPart[] attachments = getMessageAttachments(); /* * getMessageAttachments() as provided by Steve Loughran in his mail * to axis-user group * http://www.mail-archive.com/axis-user@xml.apache.org/msg08732.html */ //Put the logic in a loop for totalAttachments for multiple // attachments. totalAttachments = attachments.length; _logger.debug(saveFile(String filename = + filename + ) - + Total Attachments Received Are: + totalAttachments); if (totalAttachments != 1) { throw new AttachmentException(Too many attachments sent [ + attachments.length + ] Please limit to 1); } //Extract the first attachment. (Since in this case we have only one attachment sent) DataHandler dh = attachments[0].getDataHandler(); //Extract the file name of the first attachment. String name = filename; _logger.debug(saveFile(String filename = + filename + ) - File received on server is: + name); //Get the streams to file and from attachment, then stream to disk is = dh.getInputStream(); file = new File(name); os = new
Attachments - AXIS Server, .NET Client
I have a spot of code I would like to contribute to the group. This class I developed can be used to detach or attach any file sent over web services. This class is intended for use on the server side, and will need just a little massaging to work in your environment. It took me several painstaking hours to get AXIS to send an attachment to a requesting .NET client, and for .NET to send an attachment to a listening AXIS server. With the help of the Steve Loughran article Fear of Attachments, and not a little of his code (thanks Steve!), I was able to get .NET clients to utilize files stored on my AXIS web server. Please forgive the Exception handling. To read Steve Loughran's article I referred to, ref: http://www.mail-archive.com/axis-user@xml.apache.org/msg08732.html - John Walker package ws.attachments; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Iterator; import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.xml.soap.AttachmentPart; import org.apache.axis.AxisFault; import org.apache.axis.Message; import org.apache.axis.MessageContext; import org.apache.axis.attachments.Attachments; import org.apache.axis.attachments.AttachmentsImpl; import org.apache.log4j.Logger; /** * This class can be used from within any AXIS web service method * * @author jwalker */ public class AttachmentTrundler { private static final Logger _logger = Logger.getLogger(AttachmentTrundler.class); public AttachmentTrundler() { } /** * Attaches the file to the outgoing response message as DIME attachment. * This attachment should be consumable by all .NET web service * clients. The clients we are using are auto-generated proxy classes * that have no knowledge of the attachment coming. The WSDL will not * contain this information. * * @param fileName The full name of the file on the local filesystem to * send to the client requesting file attachment * @return true, indicating attachment was successful. * * @throws AttachmentException */ public boolean attachFile(File file) throws AttachmentException { try { MessageContext msgContext = MessageContext.getCurrentContext(); Message resMsg = msgContext.getResponseMessage(); //Get the file from the filesystem FileDataSource fileDS = new FileDataSource(file); DataHandler handler = new DataHandler(fileDS); //Create the attachment as a DIME attachment AttachmentPart attachment = resMsg.createAttachmentPart(); resMsg.getAttachmentsImpl().setSendType(AttachmentsImpl.SEND_TYPE_DIME); attachment.setDataHandler(handler); //You can set the content type to be anything you wish. All my files are zips attachment.setContentType(zip); resMsg.addAttachmentPart(attachment); }catch (Exception e) { //I know some will argue about the wisdom of catching Exception, and then // throwing AttachmentException, and they would probably be right. _logger.error(attachFile(File file = + file + ), e); throw new AttachmentException(There was a problem attaching the file to the web service call, e); } return true; } /** * This method receives the DIME encoded attachment from the client and * saves it on the server. * * @param filename as the name to save the file on the server * @return a java.io.File that represents the object on the file system * * @throws AttachmentException This exception is thrown if anything * goes wrong within the detachment process. */ public File detachFile(String filename) throws AttachmentException { InputStream is = null; FileOutputStream os = null; File file = null; int totalAttachments ; try { //Get all the attachments AttachmentPart[] attachments = getMessageAttachments(); /* * getMessageAttachments() as provided by Steve Loughran in his mail * to axis-user group * http://www.mail-archive.com/axis-user@xml.apache.org/msg08732.html */ //Put the logic in a loop for totalAttachments for multiple // attachments. totalAttachments = attachments.length; _logger.debug(saveFile(String filename = + filename + ) - + Total Attachments Received Are: + totalAttachments); if (totalAttachments != 1) { throw new AttachmentException(Too many attachments sent [ + attachments.length + ] Please limit to 1); } //Extract the first attachment. (Since in this case we have only one attachment sent) DataHandler dh = attachments[0].getDataHandler(); //Extract the file name of the first attachment. String name = filename; _logger.debug(saveFile(String filename = + filename + ) - File received on server is: + name); //Get the streams to file and from attachment, then stream to disk is = dh.getInputStream(); file = new File(name); os = new FileOutputStream(file);