【发布时间】:2014-09-23 11:22:21
【问题描述】:
我正在尝试配置一项服务,以便从 silverlight 4 应用程序通过 https 和 http 进行访问。我可以通过 https 但不能通过 http 访问该服务。我在网上做了一些研究,但似乎无法正确配置。
以下是我的 web.config 文件中的当前设置。
<system.serviceModel>
<bindings>
<customBinding>
<binding name="MyhttpsBinding">
<binaryMessageEncoding/>
<httpsTransport/>
</binding>
<binding name="MyhttpBinding">
<binaryMessageEncoding/>
<httpTransport/>
</binding>
</customBinding>
</bindings>
<services>
<service name="MyData" behaviorConfiguration="MyData">
<endpoint address="" binding="customBinding" bindingConfiguration="MyData.customBinding.https" contract="MyData"/>
<endpoint address="" binding="customBinding" bindingConfiguration="MyData.customBinding.http" contract="MyData"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyData" >
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
下面是我的 ServiceReferences.ClientConfig 文件
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DataS" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
<binding name="DataS1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
<customBinding>
<binding name="CustomBinding_GetData">
<binaryMessageEncoding />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="//localhost/MyApp/Webservice/Data.asmx"
binding="basicHttpBinding" bindingConfiguration="DataS1"
contract="ServiceReference1.DataS" name="DataS" />
<endpoint address="//localhost/MyApp/Webservice/GetData.svc"
binding="customBinding" bindingConfiguration="CustomBinding_GetData"
contract="GetData.GetData" name="CustomBinding_GetData" />
</client>
</system.serviceModel>
我上面的错误配置是什么导致对服务的调用在 http 上失败。
【问题讨论】:
-
您已经直接检查了服务端点(通过浏览器,而不是 silverlight 应用程序)并且它不会在 HTTP 中加载?可以肯定的是,您没有用任何安全属性在代码中装饰您的服务类,对吗?
-
通过浏览器直接检查服务端点适用于 http 和 https
-
我相信从 https 托管的 Silverlight 根本不会调用 http 服务。就像您在 https 上浏览网站,但某些网站内容来自 http 时,浏览器会弹出该警告消息。对于 Silverlight,它发现了相同的漏洞,并且根本不发出请求。您可以尝试通过在应用打开的情况下监控网络流量来获取更多详细信息。运行您的 Silverlight,打开浏览器调试器工具,然后查找您预期的服务调用。
标签: web-services wcf service-model