Directory
- Introduction
- Generation example
- Conclusion
- Other resources
This article is the second part of a series of articles describing how to use Business Connectivity Services to create and implement declarative Web Services (four parts in total ).
- WCF: Build a WCF Web Service for SharePoint 2010 Business Connectivity Services (part 1, part 4)
- WCF: determine the identity of the caller in the WCF Web Service (part 1, Part 4 in total) (this article)
- WCF: Establish a trust relationship between the WCF Web Service and the SharePoint 2010 Security token service (part 1, Part 4 in total)
- WCF: Use the declared WCF Web service as the external content type of SharePoint 2010 (part 1, Part 4 in total)
Introduction
With Windows Identity Foundation (WIF), you can control the Identity Logic more effectively. You can use WIF to determine the identity of the caller from the Web service. The examples provided in this article are enhanced in the previous article in this series (WCF: Building a WCF Web Service for SharePoint 2010 Business Connectivity Services (part 1, Part 4 in total, to determine the identity of the caller. Each time a Web Service is called, it adds the identity of the user who called the Web service to the log file. In this way, you can check the log file to view the identity of the caller.
Sample generation
Download and install Windows Identity Foundation (this link may point to the English page ). Install WIF on the same computer that generates the Windows Communication Foundation (WCF) Web service.
To generate a Web service, open the first article in this series (WCF: Building a WCF Web Service for SharePoint 2010 Business Connectivity Services (part 1, part 4 )) project created in
Add a reference to the Microsoft. IdentityModel assembly. In Microsoft Visual Studio 2010 or Visual Studio 2008, click Project"And then click "add reference".
Click Browse"Tab. Browse to % ProgramFiles %/Reference Assemblies/Microsoft/Windows Identity Foundation/v3.5.
Figure 1. Location of Windows Identity Foundation assembly
Select Microsoft. IdentityModel. dll"And then click OK".
Figure 2. Select Windows Identity Framework DLL
SetCustomers. svc. csWith the following code.
VBC #C ++ F # JScript ReplicationThis language is not supported or there are no available code examples.
Regenerate the application. Because it is carried by Internet Information Services, we do not need to perform any operation to activate the re-generated service.
PassWcftestclientUse Web Services.
Start the Visual Studio command prompt.
TypeWcftestclientTo run the WCF test client.
Click file"And then click "add service".
Type http: // localhost/Mers MERs/Customers. svc as the endpoint address, and then click OK".
Figure 3. type the endpoint address in the WCF test Client
If a service is successfully added, the public method of the service is displayed.
Figure 4. display the method's WCF test Client
Double-click "getallmers MERs"Method. This opens a window where you can configure requests and call requests.
Click "call"To call "GetAllCustomers"Method.
Figure 5. Data in the WCF test Client
After calling the Web service, browse to C:/MyWebService and check log.txt. Log files are similar to the following:
CopyGetAllCustomers: Identity: CONTOSO/ericwhite
Conclusion
In this article, you have completed the second step of creating a declarative Web service and using Business Connectivity Services to take advantage of the service. You have improved the Web Services created in WCF: for SharePoint 2010 Business Connectivity Services (part 1, part 4, added the WIF code to determine the identity of the caller and write the identity to the log file. In the next article (WCF: Establish a trust relationship between the WCF Web Service and the SharePoint 2010 Security token service (part 1, part 4, you will establish a trust relationship between the Web Service and the SharePoint 2010 Security token service (STS) according to the corresponding process.