Compartir a través de


Creating a Proxy Reference By Using Visual Studio 2005 or Visual Studio 2008

Last modified: October 15, 2009

Applies to: Exchange Server 2007 | Exchange Server 2010

This topic describes how to create proxy classes by using Microsoft Visual Studio 2005 or Microsoft Visual Studio 2008 and the Add Web Reference user interface. You can use this procedure to create the complete set of proxy classes and enumerations that you need to build a client application.

Note

You can also use the Web Service Description Language Tool (Wsdl.exe) to create the proxy class. For more information, see Web Service Description Language Tool (Wsdl.exe) on MSDN.

Prerequisites

  • Visual Studio 2005 with the Visual Web Developer and C# components and an open Visual Studio 2005 solution.

    Or

    Visual Studio 2008 with the Visual Web Developer and C# components and an open Visual Studio 2008 solution.

  • A computer that is running Microsoft Exchange Server 2010 that has the Client Access server role installed.

Procedure

To add a Web reference to a Visual Studio 2005 project

  1. In the Solution Explorer pane in Visual Studio 2005, right-click References, and click Add Web Reference. This opens the Add Web Reference window.

    Solution Explorer, Add Web Reference

  2. Type the URL of the wsdl file that describes the location of the Client Access server that hosts Exchange Web Services; for example, https://myClientAccessServer.myDomain.com/EWS/Services.wsdl, where myClientAccessServer.myDomain.com is the fully qualified domain name (FQDN) of the Client Access server.

    Add Web Reference

  3. Click Go. Visual Studio 2005 will attempt to connect to the Client Access server. If a server authentication certificate is not installed on the client computer, a Security Alert will appear, and you will need to install the certificate.

    Important

    If you do not install the server authentication certificate, you will not be able to add the reference to the Add Web Reference dialog box. A default Exchange Server installation tries to secure communications by creating a self-signed certificate. These certificates are safe for internal consumption, but do require all client applications to explicitly trust them. If you do not see this dialog box, an IT administrator may have updated your workstation with a trusted signature, installed a trusted certificate on the Exchange server, or both.

    To install the server authentication certificate:

    1. Click View Certificate.

      Security Allert, View Certificate

      Note

      If the Security Alert window does not have a View Certificate button, restart Visual Studio and begin the procedure to add the Web reference again. On Microsoft Windows Vista, even if you are running Visual Studio 2005 as an administrator, you do not have the View Certificate option. Run an instance of Microsoft Internet Explorer as an administrator, navigate to the /ews/exchange.asmx URL, and then step through the Security Alert dialog box.

    2. In the Certificate window, click Install Certificate. Follow the instructions in the Certificate Import wizard.

      Certificate Information, Install Certificate

    3. In the Security Alert window, click Yes to proceed.

    4. In the dialog box that appears, provide the credentials of a mailbox user.

  4. In the Web reference name field, type ExchangeWebServices.

  5. Click Add Reference. This creates the proxy types and members in a file called Reference.cs.

  6. In the directives section of the class code file that contains type references to Exchange Web Services, add a reference to the proxy classes. For example, for C#, use the using directive. The using directive will take the following form: using <namespace>.ExchangeWebServices, where <namespace> is the namespace of the code file. You can verify the namespace name in the Reference.cs file. This file may be hidden in Solution Explorer. To show hidden files, toggle the Show All Files button at the top of the Solution Explorer pane.

To add a Web reference to a Visual Studio 2008 project

  1. In the Solution Explorer pane in Visual Studio 2008, right-click References, and click Add Service Reference. This opens the Add Service Reference window.

    Add Service Reference in VS Solution Explorer

  2. In the Add Service Reference window, click Advanced. This opens the Service Reference Settings window.

    Add Service Reference window in VS 2008

  3. In the Service Reference Settings window, click Add Web Reference. This opens the Add Web Reference window.

    Service Reference Settings window in VS 2008

  4. Type the URL of the WSDL file that describes the location of the Client Access server that hosts Exchange Web Services; for example, https://myClientAccessServer.myDomain.com/EWS/Services.wsdl, where myClientAccessServer.myDomain.com is the fully qualified domain name (FQDN) of the Client Access server.

    Add Web Reference

  5. Click Go. Visual Studio 2008 will try to connect to the Client Access server. If a server authentication certificate is not installed on the client computer, a Security Alert will appear, and you will need to install the certificate.

    Important

    If you do not install the server authentication certificate, you will not be able to add the reference to the Add Web Reference dialog box. A default Exchange Server installation tries to secure communications by creating a self-signed certificate. These certificates are safe for internal consumption, but do require all client applications to explicitly trust them. If you do not see this dialog box, an IT administrator may have updated your workstation with a trusted signature, installed a trusted certificate on the Exchange server, or both.

    To install the server authentication certificate:

    1. Click View Certificate.

      Security Allert, View Certificate

      Note

      If the Security Alert window does not have a View Certificate button, restart Visual Studio and begin the procedure to add the Web reference again. On Windows Vista, even if you are running Visual Studio 2008 as an administrator, you do not have the View Certificate option. Run an instance of Microsoft Internet Explorer as an administrator, navigate to the /ews/exchange.asmx URL, and then step through the Security Alert dialog box.

    2. In the Certificate window, click Install Certificate. Follow the instructions in the Certificate Import wizard.

      Certificate Information, Install Certificate

    3. In the Security Alert window, click Yes to proceed.

    4. In the dialog box that appears, provide the credentials of a mailbox user.

  6. In the Web reference name field, type ExchangeWebServices.

  7. Click Add Reference. This creates the proxy types and members in a file called Reference.cs.

  8. In the directives section of the class code file that contains type references to Exchange Web Services, add a reference to the proxy classes. For example, for C#, use the using directive. The using directive will take the following form: using <namespace>.ExchangeWebServices, where <namespace> is the namespace of the code file. You can verify the namespace name in the Reference.cs file. This file may be hidden in Solution Explorer. To show hidden files, toggle the Show All Files button at the top of the Solution Explorer pane.

Next Steps

After you create the proxy reference, set up the ExchangeServiceBinding proxy class and configure X509 certificates for SSL over HTTP.