Gsoap,从旧版本迁移- XML响应名称和结构已更改
gsoap, migrate from old version - xml response name and structure has changed
我们有一个cgi,我必须从旧的gsoap版本迁移到gsoap 2.8.14。不幸的是,人们的反应并不相同。我添加了//gsoap的模式形式:不合格到header,但这还不足以摆脱所有ns前缀。第二个可能也是最主要的问题是响应命名。在loginResponse中,进一步的LoginResult现在被称为result和packet。
旧cgi的响应:
<LoginResult>
<successful>true</successful>
<token>example</token>
</LoginResult>
new cgi
响应<ns:loginResponse>
<result>
<successful>true</successful>
<token>example</token>
</result>
</ns:loginResponse>
我使用soapcpp2 -e -S auth.h构建存根
auth.h是这样的:
//gsoap ns service name: auth
//gsoap ns service style: rpc
//gsoap ns service encoding: encoded
//gsoap ns service port: http://domain.xy/cgi-bin/auth.cgi
//gsoap ns service namespace: urn:auth
//gsoap ns schema form: unqualified
typedef std::string xsd__string;
// array of strings containing all tags allowed for a specific user
class TagsArray
{
public:
xsd__string *__ptr;
int __size;
TagsArray();
};
// getTags.... result struct
class TagsResult
{
public:
bool successful;
xsd__string errorMessage;
TagsArray tags;
TagsResult();
};
// login result struct
class LoginResult
{
public:
bool successful;
xsd__string token; // also used as error message if successful == false
LoginResult();
};
// verify result struct
class VerifyResult
{
public:
bool successful;
xsd__string newToken; // also used as error message if successful == false
VerifyResult();
};
// contains a valid auth method for a specific realm
class ns__AuthMethod
{
public:
int id;
xsd__string description;
};
// array of all allowed authmethods for a specific realm
class AuthMethodArray
{
public:
ns__AuthMethod *__ptr;
int __size;
};
// a login parameter, usually username, pin, token
class ns__LoginParameter
{
xsd__string param;
xsd__string value;
};
// array of all submitted login parameters, depending on the authmethod that is used
class LoginParameterArray
{
public:
ns__LoginParameter *__ptr;
int __size;
};
// retrieve all possible authmethods for a specific realm
int ns__getAuthMethods(xsd__string realm, xsd__string user, AuthMethodArray &result);
// login and retrieve a valid token if succeeded
int ns__login(xsd__string realm, int authmethod, LoginParameterArray params, LoginResult &result);
// verify a existing token
int ns__verifyToken(xsd__string realm, xsd__string token, VerifyResult &result);
任何想法?谢谢。
----------------- 05.04.2013 ---------------谢谢你,戴夫!
更改完成:
- ns__前缀由Dave建议
- 删除构造函数
set bool默认值为false
//登录结果结构类ns_ LoginResult{公众:Bool成功= false;xsd _string令牌;//如果成功也用作错误消息== false
};
结果现在看起来像这样:
<ns:LoginResult>
<successful>true</successful>
<token>example</token>
</ns:LoginResult>
int ns__login(xsd__string realm, int authmethod, LoginParameterArray params, ns__LoginResult &result);
ns:前缀被所有客户端处理(php, .net, c++(qt))没有问题。
您需要在auth.h中更改LoginResult:
// login result struct
class ns__LoginResult
{
public:
bool successful;
xsd__string token; // also used as error message if successful == false
LoginResult();
};
同时修改ns_login()方法如下:
int ns__login(xsd__string realm, int authmethod, LoginParameterArray params, ns__LoginResult &result);
生成的响应如下所示:
<ns:LoginResult>
<successful>false</successful>
<token></token>
</ns:LoginResult>
希望LoginResult移到"ns"命名空间不会对您造成太大的问题。
相关文章:
- 如何循环打印顶点结构
- 通过方法访问结构
- 使用不带参数的函数访问结构元素
- 预处理器:插入结构名称中的前一个行号
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 孤立代码块在结构中引发异常
- 有什么方法可以遍历结构吗
- 如何在 C# 中映射双 C 结构指针?
- 如何在C++中使用结构生成映射
- 无法将结构注册为增强几何体3D点
- 多成员Constexpr结构初始化
- C++将文本文件中的数据读取到结构数组中
- 如何重构类层次结构以避免菱形问题
- 如何在C++中序列化结构数据
- std::vector的包装器,使数组的结构看起来像结构的数组
- 没有为自己的结构调用列表推回方法
- 奇怪的结构&GCC&clang(void*返回类型)
- 在 c++ 中拥有一组结构的正确方法是什么?
- vscode g++链路故障:体系结构x86_64的未定义符号
- Gsoap,从旧版本迁移- XML响应名称和结构已更改