2

I am writing a web service in gsoap. When i compile this code, it gives me error:
Syntax Error: Declaration Expected
When i remove vector, it compiles successfully,

#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);
Kahn
  • 755
  • 3
  • 11
  • 28

2 Answers2

3

The only error is that you should have included the import statement:
#import "stlvector.h"
NOT
#include "stlvector.h"

Before that, stlvector.h file should be in your working directory. In my case, i copied from /usr/share/gsoap/import/ to my Desktop folder where i stored my project files.
Source: gSoap Documentation

0

Hmm, perhaps a namespace clash of some sort? For example "info" is an object declared in the stdsoap2.h header.

  • I tried other names as well, but this does not seem to be the problem. – Kahn Mar 13 '13 at 02:51
  • Certainly strange. The issue does not seem to be in the code you included. As far as I can tell, you don't use the soap header in the cut-down case you included. Perhaps try to comment it out and see if the problem goes away. Like most headers, it probably has a fair bit of conditional compilation based on platform. It could be that it has a bug that shows up on your platform. It may not be a bad idea to look at the preprocessed file (use something like -E to preprocess only). – Nemanja Ivanovic Mar 13 '13 at 03:03
  • When i comment the std::vector info; the program compiles successfully. The only problem is in the vector part. – Kahn Mar 13 '13 at 03:09
  • There is ultimately nothing wrong with your code. I would find it hard to believe that whatever compiler you are using has such an obvious bug. You have to do some experimenting to find the actual bug. Just because it compiles with the vector commented out does not mean that the semantics are what you expect. Try a gradual approach where you use no headers and declare your own template in the std namespace. Then start transforming that code into what you posted. – Nemanja Ivanovic Mar 13 '13 at 03:22