[gsoap] [C]未定义SOAP_TYPE_wchar

时间:2019-03-05 09:25:39

标签: c unicode gsoap

我坚持使用gsoap 2.7.13(wsdl2h v1.2.1和soapcpp2 v2.7.13)。当我尝试将字符串映射到纯C项目中的宽字符时,遇到很多编译错误(SOAP_TYPE_wchar未定义)。

有人像我一样尝试过相同的问题吗?

此致

我的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

还有我的命令行:

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

1 个答案:

答案 0 :(得分:0)

解决此问题的补丁程序:

  1. 编辑gsoap/src/symbol2.c第11201行并插入
  if (is_wstring(typ)) /* wchar_t* is serializable but wchar_t is transient */
    return 0;

函数is_transient的第一部分应如下所示:

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. 再次运行make,您可以在gsoap/src目录中执行此操作。这将在gsoap/src目录中构建soapcpp2。将soapcpp2复制到您的项目或$PATH上的bin目录中。