向Silverlight 4应用程序添加Service引用时,ServiceReferences.ClientConfig文件生成为空

时间:2011-01-21 06:07:33

标签: silverlight wcf service-reference

我有一个通过SSL(https)托管的WCF服务,其web.config是这样的:

<system.serviceModel>
<services>
<service name="MyProject.HTMLService" behaviorConfiguration="HTMLServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://someip/HTMLService.svc"/>
<add baseAddress="https://hostname/HTMLService.svc"/>
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding"  bindingConfiguration="https" contract="MyProject.IHTMLService"/>

</service>
</services>
<bindings>
<webHttpBinding>
<binding name="https">
<security mode="Transport"/>
</binding>
</webHttpBinding>
</bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="HTMLServiceBehavior">
          <serviceMetadata httpsGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

ClientAccessPolicy.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="http://*"/>
  <domain uri="https://*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

当我尝试将服务引用添加到我的silverlight 4应用程序中时,所有必需文件都已生成,但ServiceReferences.ClientConfig文件仅包含标记。另外,configuration.svcinfo和configuration91.svcinfo文件没有Bindinds,EndPoints和Behavior配置。

如何解决这个问题? 感谢..

1 个答案:

答案 0 :(得分:0)

AFAIK在任何版本的SL中都不支持webHttpBinding

More info and hints on a way to access a rest service from an SL application

没有提供WCF中提供的WebHttpBinding的模拟信息。要从Silverlight 3访问纯HTTP,REST,RSS / Atom或AJAX服务,请使用直接访问HTTP和基于REST的服务中描述的技术,例如WebClient类。要访问ASP.NET AJAX服务,请参阅访问ASP.NET AJAX服务。