2011-02-13 75 views
1

我正在尝试向我的Silverlight客户端添加一个WCF端点行为。不过,我在运行时遇到以下错误:Silverlight客户端是否支持WCF行为?

Unrecognized element 'behaviors' in service reference configuration. 
Note that only a subset of the Windows Communication Foundation 
configuration functionality is available in Silverlight. 

WCF端点确实无法在Silverlight中扩展吗?我ServiceReferences.ClientConfig文件列表如下展示如何,我想添加一个名为MyBehaviorExtention的一个推广:

<configuration> 

    <system.serviceModel> 

     <extensions> 
      <behaviorExtentions> 
       <add 
        name="MyBehaviorExtention" 
        type="MyTest, 
          MyBehaviorExtention, 
          Version=1.0.0.0, 
          Culture=neutral, 
          PublicKeyToken=null" /> 
      </behaviorExtentions> 
     </extensions> 

     <behaviors> 
      <endpointBehaviors> 
       <behavior name="MyBehavior"> 
        <MyBehaviorExtention /> 
       </behavior> 
      </endpointBehaviors> 
     </behaviors> 

     <bindings> 
      <basicHttpBinding> 
       <binding 
        name="MyWebServicePortBinding" 
        maxBufferSize="2147483647" 
        maxReceivedMessageSize="2147483647"> 
        <security mode="None" /> 
       </binding> 
      </basicHttpBinding> 
     </bindings> 

     <client> 
      <endpoint 
       name="MyWebServicePort" 
       address="http://localhost:8080/MyService" 
       binding="basicHttpBinding" 
       bindingConfiguration="MyWebServicePortBinding" 
       contract="MyServiceReference.MyWebService" 
       behaviorConfiguration="MyBehavior" /> 
     </client> 

    </system.serviceModel> 

</configuration> 

回答

0

如果这不是在你的服务器端的web.config走呢? ServiceReferences.ClientConfig应包含有关WebService参考信息的信息,例如端点地址等。它包含服务的地址,并在编译生成的.xap文件中进行编译。

这里是我的web.config的样本,我使用行为扩展:

<extensions> 
     <behaviorExtensions> 
     <add name="silverlightFaults" type="MyApp.Web.Services.SilverlightFaultBehavior, MyApp.Web"/> 
     </behaviorExtensions> 
    </extensions> 

    <behaviors> 
     <endpointBehaviors> 
     <behavior name="SilverlightFaultBehavior"> 
      <silverlightFaults /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name=""> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

这是我所需要的。我的ServiceRefeferences.ClientConfig只包含端点地址。它仅包含Windows Communication Foundation(WCF)客户端配置的子集

+0

我的服务器是Java - 所以没有服务器端web.config。在客户端上,我只是试图添加一个消息检查器作为行为的端点。我能够以编程方式(在客户端)完成它,并想知道为什么我无法通过配置来完成它。 – Naresh 2011-02-14 20:11:24