WCF: determine the identity of the caller in the WCF Web Service (part 1, Part 4 in total)

Source: Internet
Author: User
Tags visual studio 2010

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
  1. 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.

  2. 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

  3. Add a reference to the Microsoft. IdentityModel assembly. In Microsoft Visual Studio 2010 or Visual Studio 2008, click Project"And then click "add reference".

  4. Click Browse"Tab. Browse to % ProgramFiles %/Reference Assemblies/Microsoft/Windows Identity Foundation/v3.5.

    Figure 1. Location of Windows Identity Foundation assembly

  5. Select Microsoft. IdentityModel. dll"And then click OK".

    Figure 2. Select Windows Identity Framework DLL

  6. SetCustomers. svc. csWith the following code.

    VBC #C ++ F # JScript Replication
    This language is not supported or there are no available code examples.
  7. 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.

  8. PassWcftestclientUse Web Services.

  9. Start the Visual Studio command prompt.

  10. TypeWcftestclientTo run the WCF test client.

  11. Click file"And then click "add service".

  12. 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

  13. Double-click "getallmers MERs"Method. This opens a window where you can configure requests and call requests.

  14. Click "call"To call "GetAllCustomers"Method.

    Figure 5. Data in the WCF test Client

  15. After calling the Web service, browse to C:/MyWebService and check log.txt. Log files are similar to the following:

    Copy
    GetAllCustomers: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.