代码之家  ›  专栏  ›  技术社区  ›  Kahn

语法错误:需要声明。为什么gsoap不能读取矢量?

  •  2
  • Kahn  · 技术社区  · 11 年前

    我正在用gsoap编写一个web服务。当我编译此代码时,它会给我错误:
    语法错误:需要声明
    当我移除向量时,它编译成功,

    #include <stdsoap2.h>
    #include <vector>
    
    //gsoap ns service name:    PersonData
    //gsoap ns service style:   document
    //gsoap ns service encoding:    literal
    //gsoap ns service namespace:   http://localhost/PersonData.wsdl
    //gsoap ns service location:    http://localhost:7777
    //gsoap ns schema namespace: urn:PersonData
    
    
    
    class PersonInfo 
    {
     public:
        std::string ID;
        std::string FirstName;
        std::string LastName;
        std::string Sex;
        std::string BirthDate;
        std::string BirthPlace;
        std::string SocialNumber;
    };
    
    class MultiplePersons
    {
    public:
           // It gives error only with vector 
        std::vector<PersonInfo> info; // **here is the error**
    };
    int ns__getSingleValue(std::string Param, std::string *result);
    
    int ns__getFullRecord(std::string Param, MultiplePersons *result);
    
    2 回复  |  直到 11 年前
        1
  •  3
  •   user2021471 user2021471    11 年前

    唯一的错误是您应该包含import语句:
    #导入“stlvvector.h”
    不是
    #包括“stlvvector.h”

    在此之前,stlvvector.h文件应该在您的工作目录中。在我的情况下,我从/usr/share/gsoap/import/复制到我的Desktop文件夹,在那里我存储了我的项目文件。
    来源:gSoap文档

        2
  •  0
  •   Nemanja Ivanovic    11 年前

    嗯,也许是某种名称空间冲突?例如,“info”是在stdsoap2.h标头中声明的对象。