适用于初学者的常规WCF服务设置

时间:2013-01-03 16:12:47

标签: wcf duplex-channel

我一般都在寻找关于wcf服务的某种反馈,我是一个完全的初学者。基本上,客户端需要将xml文件和图像传输到服务,并且能够从服务中下载数据集/或xml文件。我已经设置了一个wsDualHttpBinding双工合约来允许这个(回调)。我的主要三个问题是:

  1. 设置双工合同是实现来回数据传输的唯一途径吗?
  2. 使用wsDualHttpBinding,我显然无法流式传输,如果我的文件大于10mb,那么让缓冲区然后将其发送到服务是正常的吗?
  3. 将.jpg图像发送到服务的最佳方法是什么?
  4. 我真的可以使用一些反馈,wcf可能非常复杂,找到正确的做事方式对初学者来说并不容易。以前关于这个主题的问题没有得到太多反馈。

    编辑:设置流后,获取不遵循http协议的端点的错误

      <binding name="duplexendpointserver"
                    maxReceivedMessageSize="2147483647"
                    transferMode="Streamed"
                    messageEncoding="Mtom">
          <security mode="TransportCredentialOnly">
            <message clientCredentialType="UserName" />
          </security>
        </binding>         <!--<reliableSession ordered="true" inactivityTimeout="00:10:00"/>-->
        <!--</binding>-->
      </basicHttpBinding>
    </bindings>
    
    
    <services>
      <service name="Votex.Service.WCFServices" behaviorConfiguration="svcbh">
        <endpoint name="duplexendpoint" address="" binding="basicHttpBinding" bindingConfiguration="duplexendpointserver" contract="Votex.Service.IWCFServices" ></endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    

1 个答案:

答案 0 :(得分:1)

Large Data and Streaming上查看此MSDN文章。

  1. 您可以设置服务,以便在没有双工合同的情况下发送和接收方法
    • void Upload(Stream uploadStream)
    • Stream Download(string fileName)
  2. 您只能使用具有以下绑定的流:BasicHttpBinding,NetTcpBinding,NetNamedPipeBinding和WebHttpBinding。
  3. 我建议您阅读我上面链接的整篇文章,这应该可以帮助您入门。