Ask a questionAsk a question
 

AnswerTransfer a File to browser using MTOM

  • Monday, November 02, 2009 11:58 AMGeorge Sebastian Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I am implementing a Webservice which allows the consumers to request for  file in in the server. I am thinking of using WSE 3.0 to do  MTOM transfer.

    I came across some information which says instead of transferring the byte stream to client I can return an IXMLSerializable type in the web method.

    So I have the following webmethod now

    [WebMethod(BufferResponse = false)]
            public DataWrapper getFile(string fileName)

    where DataWrapper is

      public class DataWrapper : IXmlSerializable, IDisposable


    I am not sure whether someone can download a file from the server using IE by directly invoking the service. So I have added another page in the web which will be accessed by the user and and that page will invoke the Web Service and return the  byte [] and then pass that to the IE.

    So my question is that.

    Is there better way to do it?

    Can a user directly invoke the webservice and get the file rather than visiting another web page. I believe with the current approach I don't get the advantage of MTOM.

    -George

Answers

  • Monday, November 02, 2009 3:50 PMJohn SaundersMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    The better way to do this is with WCF. WSE is obsolete.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
  • Tuesday, November 03, 2009 5:16 PMAnand.Ranganathan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi George,

     Going through the previous posts in this thread , I realize that you want to allow a remote user to download a file from your webservice and you are planning to use MTOM /WSE3.0 to achieve this  . Here are couple of observations /points to ponder :

      1. The remote user will not be able to download the file by directly invoking the webservice . Since the Test webpage for your webservice is not intended to do that job.

     2. Secondly, if you are using a webpage which will call your webservice then you can use MTOM [using WSE 3.0] between your webservice and the webpage only but to a remote user this will be of no use as all what the remote user interacts is with the webpage only . Hence you can take advantage of MTOM/WSE 3.0 can only be leveraged between the Webservice and webpage only , because from your webpage you need to use/rely on the Response Object to carry the byte[] to the remote user.  

    3. So , inorder to take advantage of MTOM/WSE 3.0 in your case the remote user needs to have an application [like a smart client application / windows application] which will directly call your webservice and then use MTOM [WSE 3.0] to retrieve the byte[] from the service.

    I hope this helps !

    Cheers
    Anand R

All Replies

  • Monday, November 02, 2009 3:50 PMJohn SaundersMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    The better way to do this is with WCF. WSE is obsolete.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
  • Tuesday, November 03, 2009 6:09 AMGeorge Sebastian Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi John,

    I certainly agree with you that I have to go the WCF way. But I have restriction of using dotnet framework 2.0 only. This is because of the fact that the my webservice should work along with the exiting application and my customer is not willing to upgrade to .net 3.0 for some reasons of his own.

    So in short I cannot use WCF I want to go the WSE 3.0 way only and I trying to figure out a way to do it.


    -George S
  • Tuesday, November 03, 2009 3:11 PMJohn SaundersMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You should be certain to make your customer aware of two facts:

    1) WSE is obsolete. By requiring that you use WSE, they are requiring that you use obsolete code that is nearly unsupported. If this applicaiton is important to them, then they might not want to be using code that is nearly unsupported.
    2) .NET 3.0 and 3.5 both use the exact same CLR as .NET 2.0. In fact, if they have updated their systems to the latest service packs, then their .NET 2.0 code is already running in exactly the same environment that it would be using if they were to upgrade to .NET 3.5. .NET 3.0 and .NET 3.5 are nothing more than a service pack and a number of separate assemblies which are not used by their .NET 2.0 code, and so cannot affect their .NET 2.0 code.

    If they still decide to use obsolete code over code that will not affect anything they currently have in production, then they will have made that decision knowingly, not based on ignorance or misunderstanding.


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
  • Tuesday, November 03, 2009 5:16 PMAnand.Ranganathan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi George,

     Going through the previous posts in this thread , I realize that you want to allow a remote user to download a file from your webservice and you are planning to use MTOM /WSE3.0 to achieve this  . Here are couple of observations /points to ponder :

      1. The remote user will not be able to download the file by directly invoking the webservice . Since the Test webpage for your webservice is not intended to do that job.

     2. Secondly, if you are using a webpage which will call your webservice then you can use MTOM [using WSE 3.0] between your webservice and the webpage only but to a remote user this will be of no use as all what the remote user interacts is with the webpage only . Hence you can take advantage of MTOM/WSE 3.0 can only be leveraged between the Webservice and webpage only , because from your webpage you need to use/rely on the Response Object to carry the byte[] to the remote user.  

    3. So , inorder to take advantage of MTOM/WSE 3.0 in your case the remote user needs to have an application [like a smart client application / windows application] which will directly call your webservice and then use MTOM [WSE 3.0] to retrieve the byte[] from the service.

    I hope this helps !

    Cheers
    Anand R