Using the adCenter API with Microsoft Visual Studio 2005 requires that you complete a process that includes four steps. Each one of the following steps represents a procedure; each is covered in this topic in the order shown:
-
Install the Microsoft.NET Framework version 3.0.
-
Create the required client proxy files by using svcutil.exe.
-
Add the newly created client proxy files to your project.
-
Add the required references to System.Runtime.Serialization.dll and System.ServiceModel.dll.
For more information and a step-by-step example of how to create a program that uses the adCenter API, see Hello Microsoft adCenter Sample in C#.
Install the .NET Framework 3.0
The adCenter API uses Windows Communication Foundation (WCF) as the basis for implementing the Reporting and Campaign Management Web services. Previous versions of the adCenter API were based on ASP.NET Web Services (ASMX). When you use Visual Studio 2005 to create a WCF client, you must have the Microsoft .NET Framework 3.0 Service Pack 1 installed on all computers that your application is run on.
The .NET Framework version 3.0 amends rather than replaces the .NET Framework version 2.0. Starting with .NET Framework 3.0, WCF components are available. They must be used with the adCenter API and the languages that are compatible with the .NET Framework.
The .NET Framework 3.0 also contains the System.ServiceModel namespace, which contains the FaultException class. You're not required to use the FaultException class; however, it's the only way to take advantage of the error-reporting functionality in the adCenter API. You'll still use the .NET Framework 2.0 for the majority of your application.
Create the Client Proxy Files
You can no longer use either the Visual Studio 2005 Web Reference tool or the WSDL tool (wsdl.exe) to create your Web service client proxy. You must use the svcutil.exe utility to create your client proxy code when using one of the languages that is compatible with the .NET Framework. When the client proxy code is generated, you then manually add the generated files to your client project.
For more information about how to use the svcutil.exe utility, see the following topics:
The svcutil.exe utility is installed with the Windows SDK for Windows Server 2008 and .NET Framework 3.5. To install svcutil.exe, you need only to select the .NET Development Tools option.
The following is an example of an svcutil.exe command that creates a client proxy for the Campaign Management Web service.
svcutil https://sandboxapi.adcenter.microsoft.com/Api/Advertiser/V6/CampaignManagement/CampaignManagementService.svc /config:app.config /messageContract /n:*,adCenter.CampaignManagementService /language:csharp /out:CampaignManagementService.cs
This command creates two files—app.config and CampaignManagementService.cs. Described as follows, they are the client proxy files that must be added to your project:
-
app.config – Contains binding and endpoint information for the Web services
-
CampaignManagementService.cs – Contains the client proxy definitions
The previously mentioned svcutil.exe command creates a client proxy whose namespace is adCenter.CampaignManagementService. The namespace name is specified by the /n option. You can change this namespace to anything you choose. If you are using more than one adCenter service in your application, you must use different names for each namespace. Otherwise, the compiler cannot distinguish between the various services.
We recommend that you use message contracts when creating your client proxy, although it isn't required. To create a client proxy that uses message contracts, use the /messageContract (/mc) option with svcutil.exe to generate message contract types. For more information about message contracts, see Message Contracts.
Add the Client Proxy Files
You must manually add the client proxy files created by the svcutil.exe utility to your Visual Studio project.
Add the Required References
You must add references to System.Runtime.Serialization.dll and System.ServiceModel.dll to your project. These two DLLs are installed with the Microsoft .NET Framework 3.0 and are in the following directory:
%WINDIR%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation