gsoap, перенести со старой версии — изменилось имя и структура ответа xml

У нас есть cgi, который я должен перенести в gsoap 2.8.14 из более старой версии gsoap.
К сожалению, ответ не совпадает.
я добавил
// схема схемы gsoap ns: неквалифицированная
в заголовок, но этого было недостаточно, чтобы избавиться от префикса 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 —————
Спасибо, Дэйв!

Изменения сделаны:

  • префикс ns__, предложенный Дейвом
  • удалил конструктор
  • установите значение по умолчанию bool в false

    // логин структуры результатов
    класс нс_LoginResult
    {
    общественности:
    bool success = false;
    XSD
    _строковый токен; // также используется как сообщение об ошибке, если успешно == 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)) без проблем.

1

Решение

Вам нужно изменить LoginResult в auth.h следующим образом:

// 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» не доставит вам особых проблем.

0

Другие решения

Других решений пока нет …