Silverlight通过ISA访问WCF服务

1 篇文章 0 订阅
1 篇文章 0 订阅

维护一个老程序,在用户增加ISA作为局域网与互联网之间的防火墙之后,在互联网上的用户就无法让页面中的silverlight访问WCF服务了,但在与服务器在同一个局域网中的用户使用照常。

使用ISA使得互联网的用户必须通过HTTPS协议访问防火墙后的WEB服务器,WCF服务host在其中,而ISA里面局域网中的用户直接使用HTTP协议来访问这个服务,ISA对HTTPS的转换是透明的。

最后的解决方案是服务端的配置不变,在silverlight的ServiceReferences.ClientConfig添加一个binding和endpoint,endpoint的address等与原有的endpoint相同,只是使用心得binding,而新的binding与原有的binding只是在security改为Transport——与HTTPS都应,在互联网用HTTPS访问服务时用新的endpoint就可以了。修改后并不是很难理解,但客户端与服务端配置不配对让人有些奇怪。

例子如下:

Web.conf中的相关配置

<system.serviceModel>
		<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
		<behaviors>
			<serviceBehaviors>
				<behavior name="FPServiceBehavior">
					<serviceMetadata httpGetEnabled="true"/>
					<serviceDebug includeExceptionDetailInFaults="false"/>
					<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
					<serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000"/>
				</behavior>
			</serviceBehaviors>
		</behaviors>
		<bindings>
			<basicHttpBinding>
				<binding name="basicHttpBinding_Service" openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00" closeTimeout="01:10:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
					<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
					<security mode="TransportCredentialOnly">
						<transport clientCredentialType="Windows"/>
					</security>
				</binding>
			</basicHttpBinding>
		</bindings>
		<services>
			<service behaviorConfiguration="FPServiceBehavior" name="WcfPlanningLibrary.PlanLine">
				<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_FPService" contract="WcfPlanningLibrary.IPlanLine">
				</endpoint>
			</service>
			<service behaviorConfiguration="ServiceBehavior" name="FPMVService">
				<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_FPService" contract="FPMVService">
				</endpoint>
			</service>
		</services>
	</system.serviceModel>


ServiceReferences.ClientConfig的相关配置

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_Service" openTimeout="00:10:00"
         receiveTimeout="00:10:00" sendTimeout="00:10:00" closeTimeout="00:10:00" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="TransportCredentialOnly" />
                </binding>
                <binding name="BasicHttpBinding_Service1" openTimeout="00:10:00"
         receiveTimeout="00:10:00" sendTimeout="00:10:00" closeTimeout="00:10:00" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="Transport" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://XXX/WCFWeb/Service.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service"
                contract="Service.Service" name="BasicHttpBinding_Service" />
            <endpoint address="https://XXX/WCFWeb/Service.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service1"
                contract="Service.Service" name="BasicHttpBinding_Service1" />
        </client>
    </system.serviceModel>
其中BasicHttpBinding_Service1是新的binding和新的endpoint的名字。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值