Home > Constructing SOAP with C++ and gSOAP 2.7.9c for Windows > Building the Windows Client


Building the Windows Client

  1. To create a non-CLR (Common Language Runtime) C++ project, open Visual Studio and choose Project types > Visual C++ > Win32.
  2. Enter a name and location for the project. This sample uses a Win32 Console Application with gsoap_sample as the name of the solution. Click OK. When you start a new C++ project, the Win32 Application Wizard appears.
    Specifythe name and location of the new projectto launch a wizard.
  3. On the Application Settings page, uncheck the Precompiled header option and click Finish. Your new project is created.
    Remove the defaultheader.
  4. Choose Project > gsoap_sample Properties.
  5. In the navigation pane, expand Configuration Properties > C/C++ and click Code Generation.
  6. Verify that the Debug and Release configurations are using the correct default runtime libraries:
    1. In the Configuration drop-down menu in the upper-left corner of the Property Pages, choose Debug.
    2. In the properties listed in the main panel, verify that Runtime Library reads Multi-threaded debug DLL (/MDd).
      Verifythat the Debug configuration is using thecorrect Runtime Library.
    3. Return to the Configuration drop-down menu in the upper-left corner and choose Release.
    4. In the properties displayed in the main panel, verify that Runtime Library reads Multi-threaded DLL (/MD).
      Verify that the Release configuration is usingthecorrect Runtime library.
    5. Click OK. You are returned to the project.
  7. In the project, replace the gsoap_sample.cpp file, included in the project, with the files in the table below.

    Before adding the source files to the plugin directory, you must change their file extensions from .c to .cpp.

    Option Description
    CyberSource sample sample.cpp
    Generated by gSOAP soapC.cpp

    soapClient.cpp

    Included in gSOAP package

    gsoap_directory\dom.cpp*

    gsoap_directory\stdsoap2.cpp

    gsoap_directory\mod_gsoap\gsoap_win\wininet\gsoapWinInet.cpp

    gsoap_directory\plugin\smdevp.cpp gsoap_directory\plugin\wsseapi.cpp *

    gsoap_directory is the directory in which you downloaded and extracted gSOAP

  8. Add the following preprocessor definitions: WIN32 and WITH_OPENSSL
    Specifythe Preprocessor definitions to be used.
  9. In the sidebar, navigate to Configuration Properties > C/C++ > General, and add the following directories to your project's Additional Include Directories:
    • gsoap_directory
    • gsoap_directory\mod_gsoap\gsoap_win\wininet
    • gsoap_directory\plugin
    • gsoap_directory\include

    Add directoriesto the AdditionalInclude Directories parameter.
  10. In the sidebar, navigate to Configuration Properties > Linker > Input, and add the following libraries; in the upper Configuration field’s drop-down menu, choose each option in turn:
    • Release: libeay32MD.lib and ssleay32MD.lib
    • Debug: libeay32MDd.lib and ssleay32MDd.lib

    Specifylibraryfiles as Additional Dependencies.
  11. Add the following directory to your project's Additional Library Directories: openssl_directory\lib\VC
    Specify a directory in the Additional Library Directoriesparameter.
  12. In gsoap_directory\stdsoap2.cpp, find the following calls:

    ASN1_item_d2i

    meth->d2i

  13. In each call, cast the second parameter (&data) as const unsigned char **. The calls now read:
    ext_data = ASN1_item_d2i(NULL, (const unsigned char **) &data, ext->value->length, ASN1_ITEM_ptr(meth->it)); ext_data = meth->d2i(NULL, (const unsigned char **) &data, ext->value->length); 
  14. If you see the following compiler error in the stdsoap2.cpp file,  

      error C2440: '=' : cannot convert from 'const char *' to 'char *

    cast the first parameter as char * as follows:

       t = strchr((char *) s, ',');

  15. Inside soap_wsse_get_BinarySecurityTokenX509, find d2i_X509 in gsoap_directory\plugin\wsseapi.cpp.
  16. To the existing cast, add const as follows: cert = d2i_X509(NULL, (const unsigned char**)&data, size); You can now test the client.