我坚持使用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

最佳答案

该补丁程序可以解决此问题:


编辑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;



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

关于c - [gsoap] [C]未定义SOAP_TYPE_wchar,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54999400/

10-11 21:18