[SF 5.0] Consuming WCF REST services from an external .NET app
Hi,
I am trying to consume the WCF rest services exposed by Sitefinity 5.0.
I understand that in order to access the services, I need to to first get authenticated by calling users.svc?AuthenticateUser and that will return the cookie I need to call other services such as getting News items.
Is that part right or has it changed in SF 5 ?
I have referenced the Telerik.Sitefinity.dll assembly and tried to call the service :
However, when the service is called I get the exception:The config file contains:var usersService =
new
WebChannelFactory<IUsers>(
"UserServiceEndpoint"
);
var usersChannel = usersService.CreateChannel();
var auth = usersChannel.AuthenticateUser(
new
Telerik.Sitefinity.Security.Credentials() UserName =
"admin"
, Password =
"[PASSWORD HERE]"
, Persistent =
true
);
<
system.serviceModel
>
<
extensions
>
<
behaviorExtensions
>
<
add
name
=
"PersistantCookieBehavior"
type
=
"Tests.PersistantCookieBehaviorExtensionElement, Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
/>
</
behaviorExtensions
>
</
extensions
>
<
behaviors
>
<
endpointBehaviors
>
<
behavior
name
=
"CookieBehaviorConfig"
>
<
PersistantCookieBehavior
/>
</
behavior
>
</
endpointBehaviors
>
</
behaviors
>
<
bindings
>
<
webHttpBinding
>
<
binding
name
=
"PagesServiceBinding"
maxReceivedMessageSize
=
"1024000000"
/>
</
webHttpBinding
>
</
bindings
>
<
client
>
<
endpoint
name
=
"UserServiceEndpoint"
binding
=
"webHttpBinding"
behaviorConfiguration
=
"CookieBehaviorConfig"
contract
=
"Telerik.Sitefinity.Security.Web.Services.IUsers"
/>
</
client
>
</
system.serviceModel
>
Yann,
"MembershipProvider"
:
""
,
"Password"
:
"yourpassword"
,
"Persistent"
:
true
,
"UserName"
:
"youruser"
Hi Tim,
"MembershipProvider"
:
null
,
"Password"
:
"MyPassword"
,
"Persistent"
:
true
,
"UserName"
:
"MyUsername"
Yann,
Can you double check that your IIS setup matches the recommended configuration? Depending on what kind of authentication you want to use, you have to configure it a little differently.
I have double checked the IIS settings and they match the recommendations.
I copied the users.svc file to the Public folder to access the authenticate operation.
However, even if i copy the received cookie to call another service such as News.svc, I keep receiving a 401 error.
I can't think of a way to access the web services using claims based authentication ( which is the default authentication method in SF 5).
I switched to Forms based authentication and i can access the services normally. ( every service is available but most need a cookie that is retrieved through a call to users/authenticate).
Can you say it so if it is not possible to access the services through an external app with Claims Based Authentication ?
If this can be done, please provide a working example.
More news on this.