• WCF 传输Stream 无觉


    [ServiceContract]     public interface IService1     {    
     
         [OperationContract]        
     
    void UploadFile(FileUploadMessage request);   
     
      }    
     
    [MessageContract]    
     
    public class FileUploadMessage     {          
     
      // 文件在根目录下的子文件夹名            
     
    [MessageHeader(MustUnderstand = true)]        
     
    public string SavePath;        
     
       ///文件名           
     
       [MessageHeader(MustUnderstand = true)]      
     
       public string FileName; 
     
       ///文件内容             
     
      [MessageBodyMember(Order = 1)]      
     
       public Stream FileData;       
     
        }
     
     
    
    
    配置文件::
     
      <system.serviceModel>     <bindings>       <basicHttpBinding>         <binding name="TransferService"            sendTimeout="00:10:00"                  transferMode="Streamed"                  messageEncoding="Text"                  textEncoding="utf-8"                  maxReceivedMessageSize="9223372036854775807">          
     
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"                maxArrayLength="2147483647" maxBytesPerRead="2147483647"                maxNameTableCharCount="2147483647"/>         </binding>       </basicHttpBinding>     </bindings>     <services>       <service behaviorConfiguration="DefaultBehavior" name="WebApplication1.Service1">         <endpoint address="" binding="basicHttpBinding"               bindingConfiguration="TransferService"               contract ="WebApplication1.IService1">         </endpoint>         <host>           <baseAddresses>             <add baseAddress="http://localhost:15246/Service1.svc" />           </baseAddresses>         </host>       </service>     </services>     <behaviors>       <serviceBehaviors>         <behavior name="DefaultBehavior">           <serviceMetadata httpGetEnabled="true" />           <serviceDebug includeExceptionDetailInFaults="true" />           <serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>         </behavior>       </serviceBehaviors>     </behaviors>     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />   </system.serviceModel>
    
    
    
    上传文件:
     
    //A服务器
     
      s1.Service1Client ser1 = new s1.Service1Client();         
                    s1.FileUploadMessage f1 = new s1.FileUploadMessage();
                    //文件的名称
                    f1.FileName = FileUpload1.FileName;
                    //路径
                    f1.SavePath = "Product";
                    //文件
                    f1.FileData = FileUpload1.FileContent;
                    // //上传文件
                    s1.IService1 channel = ser1.ChannelFactory.CreateChannel();
                    channel.UploadFile(f1);
     
    //b服务器器
     
     s2.Service2Client ser2 = new s2.Service2Client();
                
                    s2.FileUploadMessage f2 = new s2.FileUploadMessage();
                    //文件的名称
                    f2.FileName = FileUpload1.FileName;
                    //路径
                    f2.SavePath = "Product";
                    //文件
                    f2.FileData = FileUpload1.FileContent;
                    // //上传文件
                    s2.IService2 channel2 = ser2.ChannelFactory.CreateChannel();
                    channel2.UploadFile(f2);
     
     
    
    
             /**********************************/
  • 相关阅读:
    ios 视频旋转---分解ZFPlayer
    IOS lame库 pcm转mp3 分析(方案二)
    IOS lame库 pcm转mp3 分析(方案一)
    ios 动态库合成包(真机&模拟器)脚本
    lame 制作ios静态库
    React Native scrollview 循环播放
    React Native Image多种加载图片方式
    汉字转拼音(包含多音字)
    React Native Alert、ActionSheet
    React Native Picker (城市选择器)
  • 原文地址:https://www.cnblogs.com/LiMin/p/3017312.html
Copyright © 2020-2023  润新知