1

我们有一个 cgi,我必须从旧的 gsoap 版本迁移到 gsoap 2.8.14。不幸的是,反应不一样。我在标题中添加了 //gsoap ns schema form: unqualified ,但这还不足以摆脱所有 ns 前缀。第二个可能也是主要问题是响应命名。进一步的 LoginResult 现在称为 loginResponse 中的结果和数据包。

来自旧 cgi 的回复:

<LoginResult>
    <successful>true</successful>
    <token>example</token>
</LoginResult>

来自新 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 --------------- 谢谢戴夫!

所做的更改:

  • Dave 建议的 ns__ 前缀
  • 删除了构造函数
  • 将布尔默认值设置为 false

    // 登录结果 struct class ns_ LoginResult { public: bool success = 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))处理,没有问题。

4

1 回答 1

0

您需要更改 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”命名空间不会对您造成太大问题。

于 2013-04-04T20:58:27.987 回答