Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C++

How do I make GSOAP support Unicode?

4.92/5 (5 votes)
3 Feb 2011CPOL1 min read 43.3K  
How do I make GSOAP support Unicode?
It's my first tip and trick, so please analyse it and give your suggestions.

Introduction
The gSOAP is an open source toolkit for SOAP/XML Web services. It is available at the link below:
GSoap 2.8.0 ->[^]

Using gSOAP, we can easily develop the SOAP and XML Web services in C/C++. We can use it to automatically convert XML to/from C and C++ data.

Purpose
GSoap does not support Unicode, this trick is helpful to make gSoap client that support Unicode data.

Steps to create gsoap client that supports unicode
1) Open command prompt.

2) Set the path of gsoap win32 folder.
cd PATH_OF_GSOAP_FOLDER\gsoap_2.8.0\gsoap-2.8\gsoap\bin\win32

3) Generate header file using wsdl2h.exe.
wsdl2h.exe -o OUTPUT_FILE_NAME.h -r xxx.xxx.xxx.xxx:xxxx PATH_OF_WSDL_FILE_NAME

Note: If proxy is enabled, than only use -r xxx.xxx.xxx.xxx:xxxx.

4) Add code in OUTPUT_FILE_NAME.h file:
class xsd__wstring : public xsd__anyType
{ public:
    std::wstring                          __item;
};


5) Update variable which you want to update on your code with std::string to std::wstring.

6) Now create client using this command:
soapcpp2.exe -I "gsoap2.8\import" -1 GSOAPCLIENT.h

7) After executing this line, a number of files are generated. These are:

a) SoapC.cpp
b) SoapH.h
c) soapClient.cpp
d) soapStub.h
e) .nsmap and .h file with same name
f) soapServer.cpp

Add these file to your source code.

Now you can send and receive Unicode data also using gSoap.

Thanks :rose:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)