C# 当通过位于不同域上的代理时,如何将WPF应用程序连接到WCF服务?
提前谢谢 我们有一个WPF应用程序位于域a中的PC上。该PC被设置为指向另一个域B上的代理 我们有一个ASP.NET WebForms站点位于承载WCF服务的域B中的web服务器上。该网站是HTTP,而不是HTTPS 代理服务器设置为使用Windows身份验证,我们希望使用30域上的特定用户来允许WPF应用程序使用它。在我们的生活中,我们无法正确设置这一点 WPF应用程序绑定配置:C# 当通过位于不同域上的代理时,如何将WPF应用程序连接到WCF服务?,c#,web-services,wcf,cross-domain,C#,Web Services,Wcf,Cross Domain,提前谢谢 我们有一个WPF应用程序位于域a中的PC上。该PC被设置为指向另一个域B上的代理 我们有一个ASP.NET WebForms站点位于承载WCF服务的域B中的web服务器上。该网站是HTTP,而不是HTTPS 代理服务器设置为使用Windows身份验证,我们希望使用30域上的特定用户来允许WPF应用程序使用它。在我们的生活中,我们无法正确设置这一点 WPF应用程序绑定配置: <system.net> <defaultProxy useDefaul
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="00:5:00" sendTimeout="00:05:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647"
maxBufferPoolSize="65536" maxReceivedMessageSize="2147483647" messageEncoding="Text"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="false" proxyAddress="http://192.168.30.221">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
网站WCF配置:
<system.serviceModel>
<services>
<service name="QuickScripts.Website.ScriptService" behaviorConfiguration="newbehaviour">
<endpoint name="default" address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService" contract="QuickScripts.Service.IService" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxDepth="32" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="newbehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
我们希望尽可能多地配置这些内容,尽管我认为这是不言而喻的
我们正在使用ChannelFactory在代码中创建客户端:
var factory = new ChannelFactory<IService>(_binding, new EndpointAddress(_url));
_instance = factory.CreateChannel();
var factory=newchannelfactory(_绑定,newendpointaddress(_url));
_instance=factory.CreateChannel();
我们还尝试通过credentials.UserName.UserName/Password向工厂应用凭据,但再次无效
所以我想主要的两个问题是,这可能吗(当然可能)?有人知道我们哪里出了问题吗?几年前我不得不这么做 我所做的是在IIS中添加一个新的端口重定向,并使用我选择的随机端口(我想我使用的是端口82)。然后我使用该端口连接到我的WCF,而不是
http://MyServer/MyService
我正在使用http://MyServer:82/MyService
完成此操作后,域管理员很容易将端口82限制为仅允许使用该应用程序的用户。那么这是使用代理的替代方案吗?在本例中不是,但与此无关。允许访问服务的凭据已通过服务通信的端口完成。我们有HTTP和HTTPS服务,我不在乎,因为凭证是在完全不同的级别上完成的。如果你的应用程序在99%的时间里使用默认端口80,并且你的管理员限制你访问互联网(再次使用端口80),那么服务将无法工作。