MSDN has a very good walkthrough on exposing and using ASP.NET Application services at this link. Unfortunately, it is marred by several technical mistakes and lack of cautionary notes on connection issues commonly encountered in distributed system.
- When creating services mapping files(.svc) for Authentication, Profile and Role application services to the web site, instead of
<%@ ServiceHost Service="System.Web.ApplicationServices.AuthenticationService" ServiceHosting="System.Web.ApplicationServices.ApplicationServicesHostFactory" %>,
it should be
<%@ ServiceHost Service="System.Web.ApplicationServices.AuthenticationService" Factory="System.Web.ApplicationServices.ApplicationServicesHostFactory" %>.
Without this change, when you point to http://localhost:8080/YourWebAppName/AuthenticationService.svc, you will get a server error, like this one:
- In the walkthrough, the application services client is a windows console application. In GetProfileInfo() method, ProfileService proxy is instantiated like this:
ProfileServiceClient profileSvc = new
ProfileServiceClient();It should be like this:
BasicHttpBinding binding = new
BasicHttpBinding();
string ProfileUri =
@"http://localhost:8080/AppServicesWalkthrough/ProfileService.svc?wsdl";
ProfileServiceClient profileSvc = new
ProfileServiceClient(binding, new
EndpointAddress(ProfileUri));
In GetUserRole() method, RoleService proxy is instantiated like this:
RoleServiceClient roleSvc = new
RoleServiceClient();It should be like this:
BasicHttpBinding binding = new
BasicHttpBinding();
string RoleUri =
@"http://localhost:8080/AppServicesWalkthrough/RoleService.svc?wsdl";
RoleServiceClient roleSvc = new
RoleServiceClient(binding, new
EndpointAddress(RoleUri));Essentially, without specifying binding info and service URI, the proxy will fail and generate the error like this one when you run the client and try to connect to application service:
- To test the client, another thing you need to do but the document fails to mention is to disable firewall. If you don't you will bump into this error:
No comments:
Post a Comment