c# - 通过 ProxyServer 发送 WCF 请求

标签 c# wcf wcf-binding wcf-extensions

这是我的客户端 WCF 配置文件:

<configuration>

  <system.net>
    <defaultProxy 
      enabled="true" 
      useDefaultCredentials="true">

      <proxy 
        usesystemdefault="False" 
        bypassonlocal="False" 
        proxyaddress="http://172.20.20.254:8088/"
      />

    </defaultProxy>
  </system.net>

<system.serviceModel>
  <client>
    <endpoint
      address="http://172.20.20.100:8080/Demo/text"
      binding="customBinding"
      bindingConfiguration="text"
      contract="DemoService.IDemoService"
      behaviorConfiguration="largeObjectGraph_behaviorConfig"
      name="text" />
  </client>

  <!-- Allow To Desrialize Larg Data -->
  <behaviors>
    <endpointBehaviors>
      <behavior name="largeObjectGraph_behaviorConfig">
        <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
      </behavior>
    </endpointBehaviors>
  </behaviors>

  <bindings>
    <customBinding>

      <binding name="text" 
               closeTimeout="10675199.02:48:05.4775807" 
               openTimeout="10675199.02:48:05.4775807"
               receiveTimeout="10675199.02:48:05.4775807" 
               sendTimeout="10675199.02:48:05.4775807">

        <CustomMessageEncoder 
              MaxArrayLength="1073741824" 
              MaxBytesPerRead="1073741824"
              MaxDepth="1073741824" 
              MaxNameTableCharCount="1073741824" 
              MaxStringContentLength="1073741824" />

        <httpTransport 
          maxBufferPoolSize="1073741824" 
          maxReceivedMessageSize="1073741824"
          maxBufferSize="1073741824" />

      </binding>
    </customBinding>
  </bindings>

  <extensions>
    <bindingElementExtensions>
      <add name="CustomMessageEncoder" type="CustomMessageEncoder.CustomMessageEncodingElement, CustomMessageEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    </bindingElementExtensions>
  </extensions>

    </system.serviceModel>
</configuration>

使用 CustomMessageEncoder 绑定(bind)来压缩和加密消息。

这里有问题:我们的 LAN 中有 Proxy-Server[172.20.20.254:8088]。

我从 ControlPannel 更改了 SystemDefaultProxy 它不起作用!

并在客户端配置文件中使用一些选项,就像你在这里看到的那样,steel 不起作用

最佳答案

这是来源:http://blogs.infosupport.com/configuring-a-proxy-server-for-wcf/

<customBinding>
  <binding name="MyCustomClientBinding">
    <binaryMessageEncoding />
    <httpTransport proxyAddress="http://gateway:8080" useDefaultWebProxy="false" />
  </binding>
</customBinding> 

关于c# - 通过 ProxyServer 发送 WCF 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16353913/

相关文章:

WCF 这可能是由于服务端点绑定(bind)未使用 HTTP 协议(protocol)

c# - WCF 服务,作为服务属性值提供的类型……找不到

c# - 通过身份验证访问 Samba 共享,无驱动器映射 - C#

c# - 有人可以解释测试驱动开发中的 "Fake it till you make it"方法吗?

c# - 使用 SoftHSM 2.2.0(带有 SHA256 的 ECDSA)C#.net 从 Pkcs11Interop 为 CKM_ECDSA_SHA256 签名 PDF

c# - 如何在防火墙后设置安全的 WCF 服务?

c# - WCF 服务中的错误报告?

WPF 绑定(bind)到 Grid.ColumnSpan

c# - 开源项目设置

c# - 我的第一个 WCF 服务器 - 为什么 OperationContext.Current 为空?