FileStream transfer

Hello!
 
Which is the easiest way to transfer file stream
from server (service) side to client side
 
Thank you in advance.
 
Best regards,
Saso


Answer this question

FileStream transfer

  • sigurdr

    Sure.

     [ServiceContract()]
     public interface ISoftwaremakerSongService
     {
     [OperationContract()]
      Boolean Upload(Stream fileStream);
     }

    ---

      public Boolean Upload(Stream fileStream)
      {
       Console.WriteLine("Saving Softwaremaker.mp3");
       DoSomeSaveFileRoutine("Softwaremaker.mp3", fileStream);
       return true;
      }

    --- (No Security Binding on Http)

      <customBinding>
       <binding configurationName="MtomSoftwaremakerDemoNOSecurity">
        <contextFlow transactions="Ignore" transactionHeaderFormat="OleTx"
        <httpTransport manualAddressing="false" maxMessageSize="65536"
         authenticationScheme="Anonymous" bypassProxyOnLocal="false"
         hostnameComparisonMode="StrongWildcard" mapAddressingHeadersToHttpHeaders="true"
         proxyAuthenticationScheme="Anonymous" realm="" transferTimeout="00:01:00"
         useSystemWebProxy="true" />
        <mtomMessageEncoding />
       </binding>
      </customBinding>

    HTH.



  • Matt Porter

    No worries. Let me know if this works and do "Mark as Correct Answer" if it is so others can learn from this as well.

  • Erik Chacon

    > Now I can't even run simple service operation on client side. Previosuly i was using wsProfileBindig. Should i also change web.config file Currently is configured like this:

    Your bindings used on the client is not the same as the ones used for the server. The best way would be to use a svcutil.exe config:/app.config to generate a corresponding client.config file. You have to make sure the bindings do correspond to each other or else it wont work.

  • Bala Atur

    Exception still occurs:

    // WEB.CONFIG
    ----------------------------------------------------------
    < xml version="1.0" encoding="utf-8" >
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
     <system.serviceModel>
      <services>
       <service
        serviceType="ProgrammingIndigo.StockQuoteService">
        <endpoint
         address=""
         bindingSectionName="customBinding"
         bindingConfiguration="stockBinding"
         contractType="ProgrammingIndigo.IStockQuote"/>
       </service>    
      </services>
      <bindings>
       <customBinding>
        <binding configurationName="stockBinding">
         <contextFlow transactions="Ignore" transactionHeaderFormat="OleTx"      
          <httpTransport manualAddressing="false" maxMessageSize="65536"
           authenticationScheme="Anonymous" bypassProxyOnLocal="false"
           hostnameComparisonMode="StrongWildcard" mapAddressingHeadersToHttpHeaders="true"
           proxyAuthenticationScheme="Anonymous" realm="" transferTimeout="00:01:00"
           useSystemWebProxy="true" />
          <mtomMessageEncoding />
         </binding>
       </customBinding>
      </bindings>
     </system.serviceModel>
     <system.web>
      <compilation debug="true"/>
     </system.web>
    </configuration>


    // APP.CONFIG
    ----------------------------------------------------------
    < xml version="1.0" encoding="utf-8" >
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
     <system.serviceModel>
      <client>
       <endpoint
        address="http://localhost/stock/service.svc"
        bindingSectionName="customBinding"    
        configurationName="StockQuoteEndpoint"
        bindingConfiguration="stockBinding"
        contractType="IStockQuote"/>
      </client>
      <bindings>
       <customBinding>
        <binding configurationName="stockBinding">
         <contextFlow transactions="Ignore" transactionHeaderFormat="OleTx"
          <httpTransport manualAddressing="false" maxMessageSize="65536"
           authenticationScheme="Anonymous" bypassProxyOnLocal="false"
           hostnameComparisonMode="StrongWildcard" mapAddressingHeadersToHttpHeaders="true"
           proxyAuthenticationScheme="Anonymous" realm="" transferTimeout="00:01:00"
           useSystemWebProxy="true" />
          <mtomMessageEncoding />
         </binding>
       </customBinding>
      </bindings>
     </system.serviceModel>
    </configuration>


    // EXCEPTION
    ----------------------------------------------------------
    Error: Unable to obtain Metadata from the Uri provided
    Error:   WS-MetadataExchange Failed on URI:http://localhost/stock/service.svc
        The remote server returned an unexpected response: (500) Internal Server Err
    or.
    Error:   HTTP Get failed on URI:http://localhost/stock/service.svc
        There was an error downloading 'http://localhost/stock/service.svc'.


    Any suggestions

    Thank you.

    Saso


  • radojko

    Ok, here is the code.

    -----------------------------------------------------
    // SERVICE

    [OperationContract]
    public bool Upload(FileStream fs)
    {
       // Create the writer for data.
       BinaryWriter w = new BinaryWriter(fs);
       // Write data
       for (int i = 0; i < 100; i++) w.Write((int)i);
       w.Close();            
       return (true);
    }       

    -----------------------------------------------------
    // CLIENT

    using (StockQuoteProxy proxy = new StockQuoteProxy("StockQuoteEndpoint"))
    {
       FileStream fs = new FileStream("c:\\test.mp3", FileMode.CreateNew);
       bool b = proxy.Upload(fs);
       fs.Close();
       proxy.Close();
    }

    -----------------------------------------------------
    When i run svcutil and parameter in service operation is FileStream, then i get following exception:

    Error: Unable to obtain Metadata from the Uri provided
    Error:   WS-MetadataExchange Failed on URI:http://localhost/stock/service.svc
        There was no endpoint listening at http://localhost/stock/service.svc that c
    ould accept the message.  This could be caused by an incorrect address or SOAP a
    ction, among other things.
    Error:   HTTP Get failed on URI:http://localhost/stock/service.svc
        The document at the url http://localhost/stock/service.svc was not recognize
    d as a known document type.
    The error message from each known type may help you fix the problem:
    - Report from 'system.web.services.discovery.discoverydocumentreference' is 'The
    re was an error downloading 'http://virtualpc/stock/service.svc disco'.'.
      - The request failed with the error message:
    --
    The service encountered an error while generating metadata. See the trace files
    for more details.

    -----------------------------------------------------
    // APP.CONFIG

    Generated with svcutil /config:app.config

    < xml version="1.0" encoding="utf-8" >
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
        <system.serviceModel>
            <client>
                <endpoint address="http://virtualpc/stock/Service.svc" bindingConfiguration="IStockQuote"
                    bindingSectionName="customBinding" contractType="IStockQuote">
                    <addressProperties actingAs="http://virtualpc/stock/Service.svc"
                        identityData="" identityType="None" isAddressPrivate="false" />
                </endpoint>
            </client>
            <bindings>
                <customBinding>
                    <binding configurationName="IStockQuote">
                        <contextFlow transactions="Ignore" transactionHeaderFormat="OleTx"
                            logicalThreadId="Ignore" locale="Ignore" />
                        <security algorithmSuite="Default" authenticationMode="SspiNegotiated"
                            contextMode="Session" defaultProtectionLevel="EncryptAndSign"
                            enableKeyDerivation="true" includeTimestamp="true" messageProtectionOrder="SignBeforeEncrypt"
                            securityVersion="WSSecurityXXX2005" secureConversationVersion="WSSecureConversationFeb2005"
                            trustVersion="WSTrustFeb2005" generateRequestSignatureConfirmation="false" />
                        <httpTransport manualAddressing="false" maxMessageSize="65536"
                            authenticationScheme="Anonymous" bypassProxyOnLocal="false"
                            hostnameComparisonMode="StrongWildcard" mapAddressingHeadersToHttpHeaders="false"
                            proxyAuthenticationScheme="Anonymous" realm="" transferTimeout="00:01:00"
                            useSystemWebProxy="true" />
                        <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                            messageVersion="Default" encoding="utf-8" />
                    </binding>
                </customBinding>
            </bindings>
        </system.serviceModel>
    </configuration>


    -----------------------------------------------------
    // WEB.CONFIG

    < xml version="1.0" encoding="utf-8" >
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
     <system.serviceModel>
      <services>
       <service
        serviceType="ProgrammingIndigo.StockQuoteService">
        <endpoint
         address=""
         bindingSectionName="customBinding"
         contractType="ProgrammingIndigo.IStockQuote"/>
       </service>    
      </services>
     </system.serviceModel>
     <system.web>
      <compilation debug="true"/>
     </system.web>
    </configuration>



    All i want is to transfer file stream in both directions, "client->server" and "server->client". Please make your own web.config, app.config  and write the service operation, which will accept FileStream parameter (upload) and service operation, which will return FileStream (download).

    THANK YOU.

    Saso



  • Bharath2k5

    First of all, thank you once again for your fast responses. I examined in details your post, and noticed, that i have syntax error in my web.config file. Then i made it up and since that everything compiles without errors, but when i run client, the exception is still there. <Exception: Unsupported Media Type> Because i need IIS hosted application, i'm using proxy solution. Config files are the same as yours. Enclosed are service and client source files, web.config, app.config and exception message.

    ----------------------------------------------------------------------
    // SERVICE
    ----------------------------------------------------------------------
    using System;
    using System.Collections.Generic;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;
    using System.Threading;
    using System.IO;


    namespace ProgrammingIndigo
    {
        // Contract definition.

        [ServiceContract]
        public interface IStockQuote
        {
            [OperationContract()]
            Boolean Upload(Stream fileStream);
        }
       
        // Service implementation.
       
        [ServiceBehavior]
        public class StockQuoteService : IStockQuote
        {
            public Boolean Upload(Stream fileStream)
            {
                Console.WriteLine("Saving file ...");
                SaveFile("Catalogue.txt", fileStream);
                return true;
            }

            public void SaveFile(string filename, Stream stream)
            {
                FileStream fileStream = File.Open("C:\\" + filename+".BAK", FileMode.Create, FileAccess.Write);

                byte[] buffer = new byte[32768];
                int i = 0;
                int totalLength = 0;

                while ((i = stream.Read(buffer, 0, buffer.Length)) > 0)
                {
                    fileStream.Write(buffer, 0, i);
                    totalLength += i;
                    //if (DownloadProgress != null)
                    //{
                    //    DownloadProgress(this, new DownloadProgressEventArgs(totalLength));
                    //}
                }

                fileStream.Close();
                stream.Close();
            }

        }
    }

    ----------------------------------------------------------------------
    // CLIENT
    ----------------------------------------------------------------------

    using System;
    using System.Collections.Generic;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;
    using System.Threading;
    using System.IO;

    namespace ProgrammingIndigo
    {
        class Client
        {
            static void Main(string[] args)
            {
                // Create a proxy.
                Console.WriteLine("Creating proxy to service.");
                using (StockQuoteProxy proxy = new StockQuoteProxy("StockQuoteEndpoint"))
                {
                    //Upload Operation
                    FileStream fileStream;
                    string filename = "c:\\catalogue.txt";
                    fileStream = File.Open(filename, FileMode.Open);
                    Console.WriteLine("catalogue.txt sent ...");
                    Console.WriteLine("Result: " + proxy.Upload(fileStream));
                    proxy.Close();
                }
               
                Console.WriteLine();
                Console.WriteLine("Press ENTER to shut down client");
                Console.ReadLine();
            }

        }
    }

    ----------------------------------------------------------------------
    // WEB.CONFIG
    ----------------------------------------------------------------------
    < xml version="1.0" encoding="utf-8" >
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
     <system.serviceModel>
      <services>
       <service
        serviceType="ProgrammingIndigo.StockQuoteService">
        <endpoint
         address="http://localhost/stock/"
         bindingSectionName="customBinding"
         bindingConfiguration="stockBinding"
         contractType="ProgrammingIndigo.IStockQuote"/>
       </service>    
      </services>
      <bindings>
       <customBinding>
        <binding configurationName="stockBinding">
         <contextFlow transactions="Ignore" transactionHeaderFormat="OleTx"/>
          <httpTransport manualAddressing="false" maxMessageSize="65536"
           authenticationScheme="Anonymous" bypassProxyOnLocal="false"
           hostnameComparisonMode="StrongWildcard" mapAddressingHeadersToHttpHeaders="true"
           proxyAuthenticationScheme="Anonymous" realm="" transferTimeout="00:01:00"
           useSystemWebProxy="true" />
          <mtomMessageEncoding />
         </binding>
       </customBinding>
      </bindings>
     </system.serviceModel>
     <system.web>
      <compilation debug="true"/>
     </system.web>
    </configuration>


    ----------------------------------------------------------------------
    // APP.CONFIG
    ----------------------------------------------------------------------
    < xml version="1.0" encoding="utf-8" >
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
     <system.serviceModel>
      <client>
       <endpoint
        address="http://localhost/stock/service.svc"
        bindingSectionName="customBinding"    
        configurationName="StockQuoteEndpoint"
        bindingConfiguration="stockBinding"
        contractType="IStockQuote"/>
      </client>
      <bindings>
       <customBinding>
        <binding configurationName="stockBinding">
         <contextFlow transactions="Ignore" transactionHeaderFormat="OleTx"/>
          <httpTransport manualAddressing="false" maxMessageSize="65536"
           authenticationScheme="Anonymous" bypassProxyOnLocal="false"
           hostnameComparisonMode="StrongWildcard" mapAddressingHeadersToHttpHeaders="true"
           proxyAuthenticationScheme="Anonymous" realm="" transferTimeout="00:01:00"
           useSystemWebProxy="true" />
          <mtomMessageEncoding />
         </binding>
       </customBinding>
      </bindings>
     </system.serviceModel>
    </configuration>


    ----------------------------------------------------------------------
    // EXCEPTION
    ----------------------------------------------------------------------
    Unhandled Exception: System.ServiceModel.ProtocolException: Content Type multipa
    rt/related; type="application/xop+xml";start="http://tempuri.org/0";boundary="uu
    id:aeb7e2e6-096e-4e3a-a000-b68a646616f3+id=1";start-info="application/soap+xml";
     action="http://tempuri.org/IStockQuote/Upload" was not supported by service htt
    p://localhost/stock/service.svc. It is possible that you have a binding mismatch
     with this service. ---> System.Net.WebException: The remote server returned an
    error: (415) Unsupported Media Type.
       at System.Net.HttpWebRequest.GetResponse()
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
    nnelRequest.WaitForReply()
       --- End of inner exception stack trace ---

    Server stack trace:
       at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebExc
    eption(WebRequest request, WebException webException)
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
    nnelRequest.WaitForReply()
       at System.ServiceModel.Channels.RequestChannel.Request(Message message)
       at System.ServiceModel.RequestChannelBinder.Request(Message message)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
    eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
    Message methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
    Msg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
    ta, Int32 type)
       at IStockQuote.Upload(Stream fileStream)
       at StockQuoteProxy.Upload(Stream fileStream) in C:\_DELOVNI\VS\Stock\client\O
    ut.cs:line 50
       at ProgrammingIndigo.Client.Main(String[] args) in C:\_DELOVNI\VS\Stock\clien
    t\Program.cs:line 24



    --------------------------------------------------------------
    --------------------------------------------------------------
    --------------------------------------------------------------
    Saso


  • rumo

    Softwaremaker, i configured app.config file on client side as follows:

    < xml version="1.0" encoding="utf-8" >
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
     <system.serviceModel>
      <client>
       <endpoint
        address="http://localhost/stock/service.svc"
        bindingSectionName="customBinding"     
        configurationName="StockQuoteEndpoint"
        bindingConfiguration="MtomSoftwaremakerDemoNOSecurity"
        contractType="IStockQuote"/>
      </client>
      <bindings>
       <customBinding>
        <binding configurationName="MtomSoftwaremakerDemoNOSecurity">
         <contextFlow
          transactions="Ignore"
          transactionHeaderFormat="OleTx"/>
             <httpTransport
           manualAddressing="false"
           maxMessageSize="65536"
           authenticationScheme="Anonymous"
           bypassProxyOnLocal="false"
           hostnameComparisonMode="StrongWildcard"
           mapAddressingHeadersToHttpHeaders="true"
           proxyAuthenticationScheme="Anonymous"
           realm=""
           transferTimeout="00:01:00"
           useSystemWebProxy="true" />
          <mtomMessageEncoding/>
         </binding>
       </customBinding>
      </bindings>
     </system.serviceModel>
    </configuration>

    Now I can't even run simple service operation on client side. Previosuly i was using wsProfileBindig. Should i also change web.config file Currently is configured like this:

    < xml version="1.0" encoding="utf-8" >
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
     <system.serviceModel>
      <services>
       <service
        serviceType="ProgrammingIndigo.StockQuoteService">
        <endpoint
         address=""
         bindingSectionName="customBinding"
         contractType="ProgrammingIndigo.IStockQuote"/>
       </service>    
      </services>
     </system.serviceModel>
     <system.web>
      <compilation debug="true"/>
     </system.web>
    </configuration>

    Please let me know, where the problem is

    THANK YOU.

    Saso


  • yanjie_li

    What do you see when you point your brower to http://localhost/stock/service.svc 

    My guess is that your soln is failing at the service-side. This could be related to incorrect settings such as the loading of the wrongtype, etc

    I am using Indigo B2-ctp now so my bits are slightly different than what you have. I will put my codes in here again. Take note of the loading of the types. I suspect this is where your sevice fails.

    As you will see below, I am simulating both sides using a console-hosted application. Once you get the hang of this, port it over to your .svc implementation for a IIS-hosted one

    --- IEchoService.cs

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;
    using System.Threading;
    using System.IO;

    namespace Service
    {
     [ServiceContract()]
     public interface IEchoService
     {
      [OperationContract()]
      Boolean Upload(Stream fileStream);
     }
    }

    --- Echo.cs

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;
    using System.Threading;
    using System.IO;
    using System.Xml;

    using Service;

    namespace BackEnd
    {
     public class Echo : IEchoService
     {
      static void Main(string[] args)
      {
       ServiceHost<Echo> echoService = new ServiceHost<Echo>();
       echoService.Open();

       Console.WriteLine("The server is running.  Press <Enter> to terminate it.");
       Console.ReadLine();
      }

      #region IEchoService Members


      public Boolean Upload(Stream fileStream)
      {
       Console.WriteLine("Saving Softwaremaker.gif");
       SaveFile("Softwaremaker.gif", fileStream);
       return true;
      }

      public void SaveFile(string filename, Stream stream)
      {
       FileStream fileStream = File.Open("C:\\" + filename, FileMode.Create, FileAccess.Write);

       byte[] buffer = new byte[32768];
       int i = 0;
       int totalLength = 0;

       while ((i = stream.Read(buffer, 0, buffer.Length)) > 0)
       {
        fileStream.Write(buffer, 0, i);
        totalLength += i;
        //if (DownloadProgress != null)
        //{
        //    DownloadProgress(this, new DownloadProgressEventArgs(totalLength));
        //}
       }

       fileStream.Close();
       stream.Close();
      }

      #endregion

     }
    }

    --- Service-side config
    < xml version="1.0" encoding="utf-8" >
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

      <system.serviceModel>

        <services>
          <service
              serviceType="BackEnd.Echo"
              behaviorConfiguration="MtomDemoSignBeforeEncrypt">
            <endpoint
              address="http://localhost:8080/EchoService"
              contractType="Service.IEchoService"
              bindingSectionName="customBinding"
              bindingConfiguration="MtomDemoSignBeforeEncrypt" />
          </service>
        </services>

        <bindings>
      <customBinding>
       <binding configurationName="MtomDemoSignBeforeEncrypt">
        <contextFlow transactions="Ignore" transactionHeaderFormat="OleTx"
         logicalThreadId="Ignore" locale="Ignore" />
        <!--<security algorithmSuite="Rsa15Aes128" authenticationMode="X509MutualAuthenticationProfile"
         contextMode="None" defaultProtectionLevel="EncryptAndSign"
         enableKeyDerivation="false" includeTimestamp="true" messageProtectionOrder="SignBeforeEncrypt"
         securityVersion="WSSecurityJan2004" secureConversationVersion="WSSecureConversationFeb2005"
         trustVersion="WSTrustFeb2005" generateRequestSignatureConfirmation="false" />-->
        <httpTransport manualAddressing="false" maxMessageSize="65536"
         authenticationScheme="Anonymous" bypassProxyOnLocal="false"
         hostnameComparisonMode="StrongWildcard" mapAddressingHeadersToHttpHeaders="true"
         proxyAuthenticationScheme="Anonymous" realm="" transferTimeout="00:01:00"
         useSystemWebProxy="true" />
        <!--<mtomMessageEncoding />-->
        <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
         messageVersion="Soap11Addressing1" encoding="utf-8" />
       </binding>
      </customBinding>
        </bindings>
      </system.serviceModel>

    </configuration>

    [WilliamTay] As you can see, I am using b64Encoding above. You can uncomment that and use mtomMessageEncoding if you would like for a more optimized approach.

    --- Copy the same IEchoService to the client-side. I am using channelFactories to instantiate a channel and not a proxy. I prefer it this way in proof of concepts and such. Of course, you can still do the proxy way.

    --- IEchoClient.cs

    using System;
    using System.Collections.Generic;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;
    using System.Threading;
    using System.IO;

    using Service;

    namespace Client
    {
     public class EchoClient
     {
      private void Act()
      {
       ChannelFactory<IEchoService> factory = new ChannelFactory<IEchoService>("EchoService");
       IEchoService echoServiceChannel = factory.CreateChannel();

       //Upload Operation
       FileStream fileStream;
       string filename = "Softwaremaker.gif";
       fileStream = File.Open(filename, FileMode.Open);
       Console.WriteLine("Softwaremaker.gif sent ...");
       Console.WriteLine("Result: " + echoServiceChannel.Upload(fileStream));
      }

      static void Main(string[] args)
      {
       Console.WriteLine("Press <Enter> when the service is running.");
       Console.ReadLine();

       EchoClient client = new EchoClient();
       Thread backgroundThread = new Thread(new ThreadStart(client.Act));
       backgroundThread.Start();

       //Console.WriteLine("Waiting for the downloaded File ... ");
       Console.ReadLine();
       
      }

            public void SaveFile (string filename, Stream stream)
            {
                FileStream fileStream = File.Open("C:\\" + filename, FileMode.Create, FileAccess.Write);

         byte[] buffer = new byte[32768];
                int i = 0;
                int totalLength = 0;

                while ((i = stream.Read(buffer, 0, buffer.Length)) > 0)
                {
                    fileStream.Write(buffer, 0, i);
                    totalLength += i;
                }

                fileStream.Close();
         stream.Close();
            }

      #region IEchoListener Members

      #endregion

     }
    }

    --- Client-side config
    < xml version="1.0" encoding="utf-8" >
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <system.serviceModel>
        <client>

          <endpoint
            configurationName="EchoService"
            address="http://localhost:8080/EchoService"
            bindingSectionName="customBinding"
            bindingConfiguration="MtomDemoSignBeforeEncrypt"
            contractType="Service.IEchoService, Client"
      behaviorConfiguration="MtomDemoSignBeforeEncrypt" />
      </client>

        <bindings>
      <customBinding>

       <binding configurationName="MtomDemoSignBeforeEncrypt">
        <contextFlow transactions="Ignore" transactionHeaderFormat="OleTx"
         logicalThreadId="Ignore" locale="Ignore" />
        <!--<security algorithmSuite="Rsa15Aes128" authenticationMode="X509MutualAuthenticationProfile"
         contextMode="None" defaultProtectionLevel="EncryptAndSign"
         enableKeyDerivation="false" includeTimestamp="true" messageProtectionOrder="SignBeforeEncrypt"
         securityVersion="WSSecurityJan2004" secureConversationVersion="WSSecureConversationFeb2005"
         trustVersion="WSTrustFeb2005" generateRequestSignatureConfirmation="false" />-->
        <httpTransport manualAddressing="false" maxMessageSize="65536"
         authenticationScheme="Anonymous" bypassProxyOnLocal="false"
         hostnameComparisonMode="StrongWildcard" mapAddressingHeadersToHttpHeaders="true"
         proxyAuthenticationScheme="Anonymous" realm="" transferTimeout="00:01:00"
         useSystemWebProxy="true" />
        <!--<mtomMessageEncoding />-->
        <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
         messageVersion="Soap11Addressing1" encoding="utf-8" />
       </binding>   
      </customBinding>
     </bindings>   
      </system.serviceModel>
     
    </configuration>

    As you can see, I am using b64Encoding above. You can uncomment that and use mtomMessageEncoding if you would like for a more optimized approach.

    [WilliamTay] As you can see, I am using b64Encoding above. You can uncomment that and use mtomMessageEncoding if you would like for a more optimized approach. Make sure the config bindings on both sides are the same !!! I really hope this helps.



  • Paul_G

    Softwaremaker,

    The command "svcutil.exe config:/app.config" successfully generated a corresponding client.config file, also service and client compiled without problems, but i still can't get file stream from service to client side.

    I'm asking you, if there is any chance to make entire vs.net project, with all corresponding files, that will demonstrate how to transfer file stream.

    If it possible, attach the project here in forum, otherwise send it to my email.

    Sorry for bothering you, but i need to solve that problem as soon as possible.

    Than you once again.

    Saso

  • Daniel Teixeira

    Saso,

    It seems that you have missed out the <customBinding> in your web.config Put the same blob of <bindings><customBinding> that I indicated to you in my earlier posts on the config on both sides.

  • mccampello

    I would just stream over the filestream using MTOM encoding

  • BryJ

    Softwaremaker, could you be so kind and write short example.

    Thank you.

    Saso


  • Hami

    What is the exception you are seeing I suspect it could be a proxy instantiating problem or are you using channelfactories

    Do a simple filestream upload operation and post it here (client and service code + the config files)

  • Hello for u

    Thank you for fast response. Exactly i would like to make download operation.
    I will let you know if i encounter any problems making it.

    Thank you once again and i hope that i don't bother you.

    Saso

  • FileStream transfer