问题
HI,
I am using WCF DataServices, i am trying to securing it using asp.net membership
here is my code,
<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>
I am getting following error:
The operation 'ProcessRequestForMessage' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.
回答1:
You can try this, if this is almost like your code:
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)
来源:https://stackoverflow.com/questions/5816788/securing-an-ado-net-wcf-data-service-with-asp-net-membership