struct ns__EmployeeInfo
{
int userid;
char* name;
};
struct ArrayOfEmp2
{struct ns__EmployeeInfo info;};
接口函數:int ns__getEmp2(void *_,struct ArrayOfEmp2 &ccc);
struct ns__ArrayOfEmp2
{struct ns__EmployeeInfo info;};
接口函數:int ns__getEmp2(void *_,struct ns__ArrayOfEmp2 &ccc);
struct ArrayOfEmp1 //此爲正確寫法
{struct ns__EmployeeInfo **__ptr;int __size;};
接口函數:int ns__getAllEmp1(void *_,struct ArrayOfEmp1 &alal);
幾個注意點:父級結構名字不要帶ns__;返回的目標結構成員的名字必須是__ptr,大小的名字必須是__size。(4)接口實現代碼
int ns__getAllEmp1(struct soap* soap,void *_,struct ArrayOfEmp1 &_return)
{
_return.__size = 5;
_return.__ptr = (struct ns__EmployeeInfo**)soap_malloc(soap,5*sizeof(struct ns__EmployeeInfo));
_return.__ptr[0] = (struct ns__EmployeeInfo*)soap_malloc(soap,sizeof(struct ns__EmployeeInfo));
_return.__ptr[0]->userid=1000;
_return.__ptr[0]->name= soap_strdup(soap,"name1");
_return.__ptr[1] = (struct ns__EmployeeInfo*)soap_malloc(soap,sizeof(struct ns__EmployeeInfo));
_return.__ptr[1]->userid=1001;
_return.__ptr[1]->name= soap_strdup(soap,"name2");
_return.__ptr[2] = (struct ns__EmployeeInfo*)soap_malloc(soap,sizeof(struct ns__EmployeeInfo));
_return.__ptr[2]->userid=1002;
//_return.__ptr[2]->name = soap_strdup(soap,"name3");
_return.__ptr[2]->name = (char*)"name3";//這種形式的複製,也是沒關係的
_return.__ptr[3] = (struct ns__EmployeeInfo*)soap_malloc(soap,sizeof(struct ns__EmployeeInfo));
_return.__ptr[3]->userid = 1003;
_return.__ptr[3]->name = (char*)"name4";
_return.__ptr[4] = (struct ns__EmployeeInfo*)soap_malloc(soap,sizeof(struct ns__EmployeeInfo));
_return.__ptr[4]->userid = t.id;
_return.__ptr[4]->name = soap_strdup(soap,t.name.c_str());
return SOAP_OK;
}
幾個作死行爲:
struct ns__ArrayOfEmp //此寫法會導致返回的結構是ArrayOfEmp,且其Item屬性爲NULL
{struct ns__EmployeeInfo **__ptr;int __size;};