当我在 WinForms 应用程序上使用它时 DefaultProxy 可以工作,但在 WCF 中不能工作?
DefaultProxy works when I use this on WinForms Application but won't works in WCF?
首先,对于任何错误,我们深表歉意。英语不是我的母语
我有一个与 SOAP WS 通信的应用程序,当我设置
<defaultProxy enabled="true" useDefaultCredentials="true">
在 WinForm 应用程序的 app.config 上,请求响应是正确的,但如果我将其放在 WCF Windows 服务的同一部分,我会得到响应:没有端点侦听。
<binding name="BasicHttpBinding_IGDServices" receiveTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" textEncoding="utf-8" useDefaultWebProxy="true"
messageEncoding="Mtom" />
<binding name="mywsname" receiveTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" useDefaultWebProxy="true">
<readerQuotas maxStringContentLength="2147483647" />
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="mywsendpoint"
binding="mywsbinding" bindingConfiguration="mywsbinding"
contract="mywscontract" name="mywsname" />
我已尝试设置代理,但收到响应:输入的字符串格式不正确
<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy proxyaddress="myproxyadressandport"/>
</defaultProxy>
两个应用程序的所有参数或方法都以相同的方式实现。
有人可以帮助我吗?
你的英语很好。代理设置是绑定配置的一部分。我们通常在绑定属性中设置代理地址。
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService" proxyAddress="myproxyaddress"/>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://10.157.13.70:8300/" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService" contract="ServiceReference1.IService"
name="WSHttpBinding_IService">
<identity>
<userPrincipalName value="VABQIA593VM\Administrator" />
</identity>
</endpoint>
</client>
</system.serviceModel>
或者,
WSHttpBinding binding = new WSHttpBinding();
binding.BypassProxyOnLocal = false;
binding.UseDefaultWebProxy = false;
binding.ProxyAddress = new Uri("http://abcd");
请参考以下官方文档
https://docs.microsoft.com/en-us/dotnet/api/system.servicemodel.basichttpbinding.proxyaddress?redirectedfrom=MSDN&view=netframework-4.0#System_ServiceModel_BasicHttpBinding_ProxyAddress
https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/wcf/basichttpbinding?redirectedfrom=MSDN
如果有什么我可以帮忙的,请随时告诉我。
首先,对于任何错误,我们深表歉意。英语不是我的母语
我有一个与 SOAP WS 通信的应用程序,当我设置
<defaultProxy enabled="true" useDefaultCredentials="true">
在 WinForm 应用程序的 app.config 上,请求响应是正确的,但如果我将其放在 WCF Windows 服务的同一部分,我会得到响应:没有端点侦听。
<binding name="BasicHttpBinding_IGDServices" receiveTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" textEncoding="utf-8" useDefaultWebProxy="true"
messageEncoding="Mtom" />
<binding name="mywsname" receiveTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" useDefaultWebProxy="true">
<readerQuotas maxStringContentLength="2147483647" />
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="mywsendpoint"
binding="mywsbinding" bindingConfiguration="mywsbinding"
contract="mywscontract" name="mywsname" />
我已尝试设置代理,但收到响应:输入的字符串格式不正确
<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy proxyaddress="myproxyadressandport"/>
</defaultProxy>
两个应用程序的所有参数或方法都以相同的方式实现。
有人可以帮助我吗?
你的英语很好。代理设置是绑定配置的一部分。我们通常在绑定属性中设置代理地址。
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService" proxyAddress="myproxyaddress"/>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://10.157.13.70:8300/" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService" contract="ServiceReference1.IService"
name="WSHttpBinding_IService">
<identity>
<userPrincipalName value="VABQIA593VM\Administrator" />
</identity>
</endpoint>
</client>
</system.serviceModel>
或者,
WSHttpBinding binding = new WSHttpBinding();
binding.BypassProxyOnLocal = false;
binding.UseDefaultWebProxy = false;
binding.ProxyAddress = new Uri("http://abcd");
请参考以下官方文档
https://docs.microsoft.com/en-us/dotnet/api/system.servicemodel.basichttpbinding.proxyaddress?redirectedfrom=MSDN&view=netframework-4.0#System_ServiceModel_BasicHttpBinding_ProxyAddress
https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/wcf/basichttpbinding?redirectedfrom=MSDN
如果有什么我可以帮忙的,请随时告诉我。