Search code examples
cunicodegsoap

[gsoap][C] Undefined SOAP_TYPE_wchar


I'm stuck with gsoap 2.7.13 (wsdl2h v1.2.1 and soapcpp2 v2.7.13). When I tried to map strings to wide chars in a pure C project, I get many compilation errors (SOAP_TYPE_wchar undefined).

Someone have experimented the same issue like me ?

Regards,

My typemap.dat

[
struct SOAP_ENV__Header
{
    _XML wsse__Security;
};
]

#   Use unicode
xsd__string = | wchar_t* | wchar_t*

#   CMIS recommended prefix
SOAP-ENV    =   "http://schemas.xmlsoap.org/soap/envelope"
SOAP-ENC    =   "http://schemas.xmlsoap.org/soap/encoding"
xsi         =   "http://www.w3.org/2001/XMLSchema-instance"
xsd         =   "http://www.w3.org/2001/XMLSchema"
ns1         =   "http://docs.oasis-open.org/ns/cmis/core/200908/"
ns2         =   "http://docs.oasis-open.org/ns/cmis/messaging/200908/"
cmis        =   "http://docs.oasis-open.org/ns/cmis/ws/200908/"
cmis2       =   "http://docs.oasis-open.org/ns/cmis/ws/200908/DiscoveryServicePortBinding"
cmis3       =   "http://docs.oasis-open.org/ns/cmis/ws/200908/MultiFilingServicePortBinding"
cmis4       =   "http://docs.oasis-open.org/ns/cmis/ws/200908/NavigationServicePortBinding"
cmis5       =   "http://docs.oasis-open.org/ns/cmis/ws/200908/ObjectServicePortBinding"
cmis6       =   "http://docs.oasis-open.org/ns/cmis/ws/200908/PolicyServicePortBinding"
cmis7       =   "http://docs.oasis-open.org/ns/cmis/ws/200908/RelationshipServicePortBinding"
cmis8       =   "http://docs.oasis-open.org/ns/cmis/ws/200908/RepositoryServicePortBinding"
cmis9       =   "http://docs.oasis-open.org/ns/cmis/ws/200908/VersioningServicePortBinding"
cmis10      =   "http://docs.oasis-open.org/ns/cmis/ws/200908/ACLServicePortBinding"

# End of file

And my command lines :

wsdl2h -c -o cmis_ws.h -t typemap.dat -x "http://docs.oasis-open.org/cmis/CMIS/v1.0/errata-01/os/schemas/CMISWS-Service.wsdl"
soapcpp2 -c -p cmis cmis_ws.h

Solution

  • The patch to correct this issue:

    1. edit gsoap/src/symbol2.c line 11201 and insert
      if (is_wstring(typ)) /* wchar_t* is serializable but wchar_t is transient */
        return 0;
    

    The first part of function is_transient should look like this:

    int
    is_transient(Tnode *typ)
    {
      if (!typ)
        return 1;
      if (typ->type == Tstruct && typ->id == lookup("soap"))
        return 1;
      if (is_external(typ) || is_volatile(typ))
        return 0;
      if (typ->transient > 0)
        return 1;
      if (is_wstring(typ)) /* wchar_t* is serializable but wchar_t is transient */
        return 0;
    
    1. run make again, you can do this in the gsoap/src directory. This builds soapcpp2 in the gsoap/src directory. Copy soapcpp2 to your project or to a bin directory on your $PATH.