I have a RIA service (CustomDomainService), which is composed by few methods that need authentication. Authentication is provided by an authentication service (AuthenticationDomainService). Everything works from Silverlight, which is the main client.
I need now to expose a couple of the existing methods via SOAP. Hence I changed my web.config configuration to allow the access via SOAP:
<domainServices>
<endpoints>
<add name="soap" type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory,
Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</endpoints>
</domainServices>
In a Windows Form Application that I’ve built for test purposes, I’ve added the reference to the SOAP webservice.
I can log in the Authentication service without any error, but I still get “Access denied” for any web method invokation on the actual service:
var auth = new myAuth.AuthenticationDomainService();
auth.Login("username", "password", true, false, "");
var svc = new myService.myDomainService();
var res = svc.GetDataByCustomerCode("", DateTime.Now, true, DateTime.Now, true);
I read around that the authentication service should return some cookies and those should be used in the actual business service. However after Login is called I cannot see any cookie in the auth.CookieContainer. Also, I don’t have any InnerChannel property, which I could use in order to grab the assigned cookie.
Could someone point out for me what I am doing wrong?
Thanks in advance,
Cheers,
G.
Ok, I’ve found out what the issue is.
I had added the two services as “old” Web Services. I removed them, and added back again, this time as standard Service References.
After that, I was able to get a “myServiceSoapClient” and a “myAuthSoapClient”, which have a InnerChannel property, that is what I needed in order to retrieve the security token cookie.
By getting the cookie from the auth sevice (after authentication) and setting it in the second service (the actual service) I have been able to access all methods I was supposed to access.
Cheers,
Gianluca.