HI,
我正在使用WCF DataServices,我正在尝试使用asp.net成员资格保护它
这是我的代码,
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="SecureWSBindingWithMembershipConfig" >
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="SecureServiceWithMembershipBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="AspNetSqlRoleProvider" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="DataService.WcfDataService" behaviorConfiguration="SecureServiceWithMembershipBehavior">
<endpoint address="WcfDataService.svc" binding="wsHttpBinding" contract="System.Data.Services.IRequestHandler" bindingConfiguration="SecureWSBindingWithMembershipConfig" >
<!--<identity>
<dns value="" />
</identity>-->
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
我收到以下错误:
无法加载“ProcessRequestForMessage”操作,因为它具有System.ServiceModel.Channels.Message类型的参数或返回类型,或者具有MessageContractAttribute的类型和其他不同类型的参数。使用System.ServiceModel.Channels.Message或使用MessageContractAttribute类型时,该方法不得使用任何其他类型的参数。
答案 0 :(得分:1)
如果这几乎与您的代码相似,您可以试试这个:
Method(RequestMessage request, OtherType value)
// Your message contract much like this.
[MessageContract]
public class RequestMessage {
[MessageBodyMember]
public OtherType { get; set; }
}
// And your new method will be
Method(RequestMessage request)