gsoap 中的重大更改(将版本从 2.8.8 更新到 2.8.16)

Breaking changes in gsoap (updating version from 2.8.8 to 2.8.16)

本文关键字:更新 版本 gsoap      更新时间:2023-10-16

我有一个使用 gSoap 的C++客户端。当它使用2.8.8版本的gSoap时,它运行良好。升级到 2.8.16 后,它停止工作。问题似乎如下:我们缺少肥皂信封。发送的旧版本:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="urn:attachmentSoapServer"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<data here>
</SOAP-ENV:Body></SOAP-ENV:Envelope>

新版本仅发送:

<data here>

如何像旧版本一样添加肥皂标题?

代码是这样的:

struct soap soap;    
soap_init(&soap);
soap_call_here(...);

请检查 wsdl2h 警告消息和生成的 .h 接口文件。

为了确保 SOAP 传输,生成的 .h 文件应具有:

//gsoap ns1 service transport: http://schemas.xmlsoap.org/soap/http

对于每个服务操作,我们期望如下:

//gsoap ns1 service method-protocol:   method SOAP

如果方法协议是HTTP(或POST,GET,PUT),那么将使用没有SOAP信封和没有SOAP正文的REST。

命名空间

不应该在 XXXBinding.h 中定义,它是由 soapcpp2 自动生成的.exe如下所示?或者必须在代码中更改它。

    MyServiceSoap12Binding()
    { 
        soap = soap_new(); 
        if (soap && !soap->namespaces) 
        {
            static const struct Namespace namespaces[] = 
            {
                {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope", NULL},
                {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding", NULL},
                {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
                {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},
                //...
                {NULL, NULL, NULL, NULL}
            };
        soap->namespaces = namespaces;
        }
    }