Skip to content

1.1 Create an OData V4 client app in Visual Studio 2012

Yi Ding edited this page Aug 8, 2014 · 16 revisions

This section is a tutorial about how to create a client application for the OData V4 service with ODataCpp using Visual Studio 2012. The ODataCpp client libraries currently only supports Visual Studio 2012. We'll add more support soon.

Generate the client side proxy of the target service

Suppose you already have your ODataCpp client libraries and code generation tools built. If you haven't, please refer to the README file for instructions.

(1) Navigate to the path of where the built libraries and tool are located

Open Command Prompt (cmd.exe) or PowerShell and type in the following command to navigate to the location:

cd <Home>\odatacpp\output\<Configuration>

<Home> is the path where your odatacpp folder is located and <Configuration> is the build configuration you've chosen to build your library (either "Debug" or "Release"). In this tutorial, we chose "Release" as the build configuration.

(2) Run the code generation tool to generate the proxy

Type in the following command in Command Prompt or PowerShell

.\odata_codegen_tool.vs11.exe <ServiceURL> <ProxyFileName> <Username> <Password>

<ProxyFileName> is the name you want for the .h and .cpp files of the proxy code. <ServiceURL> is the URL of the service document of the target OData service. <Username> and <Password> are the credential for accessing the service in case it requires authentication.

In this tutorial, we want to build a client application for the TripPin service published on www.odata.org and it doesn't require authentication, so we type in the following command:

.\odata_codegen_tool.vs11.exe http://services.odata.org/v4/TripPinServiceRW TripPinService

and we get the following two proxy files: The generated proxy files for the TripPin service

Create an client app in Visual Studio 2012 and include the generated proxy

(1) Open Visual Studio 2012 and create an empty C++ project Create an empty C++ project in Visual Studio 2012

(2) Add the proxy files and client libraries to the project Add the proxy files and client libraries to the project

  • Add "TripPinService.h" to "Header Files"
  • Add "TripPinService.cpp" to "Source Files"
  • Add "odata_client.vs11.dll", "odata_client.vs11.lib", "odata_library.vs11.dll", "odata_library.vs11.lib", "utilities.vs11.dll", "utilities.vs11.lib" to the project.