我有一个使用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>
如何添加类似于旧版本的soap标头?
代码是这样的:
struct soap soap;
soap_init(&soap);
soap_call_here(...);
答案 0 :(得分:0)
命名空间不应该在 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;
}
}
答案 1 :(得分:0)
请检查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 Envelope且没有SOAP Body的REST。