Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 无法使用C+;编译gsoap生成的服务器代码+;建设者_C++_C++builder_Gsoap - Fatal编程技术网

C++ 无法使用C+;编译gsoap生成的服务器代码+;建设者

C++ 无法使用C+;编译gsoap生成的服务器代码+;建设者,c++,c++builder,gsoap,C++,C++builder,Gsoap,我正在尝试使用GSOAP2.8.17构建一个服务器应用程序。我已经用服务函数原型和结果记录定义创建了一个头文件 testserver.h: #ifndef TESTSERVER_H #define TESTSERVER_H #include <string> //gsoap ns service name: TestServer //gsoap ns service namespace: http://mycomp:8080/TestServer.wsdl //gsoap ns

我正在尝试使用GSOAP2.8.17构建一个服务器应用程序。我已经用服务函数原型和结果记录定义创建了一个头文件

testserver.h:

#ifndef TESTSERVER_H
#define TESTSERVER_H

#include <string>

//gsoap ns service name: TestServer
//gsoap ns service namespace: http://mycomp:8080/TestServer.wsdl
//gsoap ns service location: http://mycomp:8080/TestServer.cgi
//gsoap ns schema namespace: urn:TestServer

class Record
{
public:
    int id;
    std::string name;
    std::string address;
    double param1;
};

int ns__GetRecord(int id, Record* result);

#endif 
编译器生成了以下文件:

soapC.cpp
soapClient.cpp
soapClientLib.cpp
soapServer.cpp
soapServerLib.cpp
soapH.h
soapStub.h
TestServer.h
TestServer.nsmap
TestServer.wsdl
TestServer.GetRecord.req.xml
TestServer.GetRecord.res.xml
ns.xsd
TestServer.wsdl

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="TestServer"
 targetNamespace="http://mycomp:8080/TestServer.wsdl"
 xmlns:tns="http://mycomp:8080/TestServer.wsdl"
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:ns="urn:TestServer"
 xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:HTTP="http://schemas.xmlsoap.org/wsdl/http/"
 xmlns:MIME="http://schemas.xmlsoap.org/wsdl/mime/"
 xmlns:DIME="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/"
 xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
 xmlns="http://schemas.xmlsoap.org/wsdl/">

<types>

 <schema targetNamespace="urn:TestServer"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:ns="urn:TestServer"
  xmlns="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="unqualified"
  attributeFormDefault="unqualified">
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
  <complexType name="Record"><!-- Record -->

   <sequence>
     <element name="id" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- Record::id -->
     <element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/><!-- Record::name -->
     <element name="address" type="xsd:string" minOccurs="1" maxOccurs="1"/><!-- Record::address -->
     <element name="param1" type="xsd:double" minOccurs="1" maxOccurs="1"/><!-- Record::param1 -->
   </sequence>
  </complexType>
  <!-- operation request element -->
  <element name="GetRecord">
   <complexType>
    <sequence>
     <element name="id" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__GetRecord::id -->
    </sequence>
   </complexType>
  </element>
  <!-- operation response element -->
  <element name="GetRecordResponse">
   <complexType>
    <sequence>
     <element name="result" type="ns:Record" minOccurs="0" maxOccurs="1" nillable="true"/><!-- ns__GetRecord::result -->
    </sequence>
   </complexType>
  </element>
 </schema>

</types>

<message name="GetRecordRequest">
 <part name="Body" element="ns:GetRecord"/><!-- ns__GetRecord::ns__GetRecord -->
</message>

<message name="GetRecordResponse">
 <part name="Body" element="ns:GetRecordResponse"/>
</message>

<portType name="TestServerPortType">
 <operation name="GetRecord">
  <documentation>Service definition of function ns__GetRecord</documentation>
  <input message="tns:GetRecordRequest"/>
  <output message="tns:GetRecordResponse"/>
 </operation>
</portType>

<binding name="TestServer" type="tns:TestServerPortType">
 <SOAP:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
 <operation name="GetRecord">
  <SOAP:operation soapAction=""/>
  <input>
     <SOAP:body parts="Body" use="literal"/>
  </input>
  <output>
     <SOAP:body parts="Body" use="literal"/>
  </output>
 </operation>
</binding>

<service name="TestServer">
 <documentation>gSOAP 2.8.17 generated service definition</documentation>
 <port name="TestServer" binding="tns:TestServer">
  <SOAP:address location="http://mycomp:8080/TestServer.cgi"/>
 </port>
</service>

</definitions>
soapStub.h(224):

SOPC.cpp(1598-1619):

SOAP\u FMAC1 struct ns\u GetRecord*SOAP\u FMAC2 SOAP\u实例化\u ns\u GetRecord(struct SOAP*SOAP,int n,const char*type,const char*arrayType,size\u t*size)
{
(void)类型;(void)数组类型;/*appease-Wall-Werror*/
DBGLOG(测试,SOAP_消息(fdebug,“SOAP_实例化__ns_获取记录(%d,%s,%s)\n)”,n,类型?类型:“”,arrayType?arrayType:);
struct soap\u clist*cp=soap\u链接(soap,NULL,soap\u类型\u ns\u GetRecord,n,soap\u fdelete);
如果(!cp)
返回NULL;
if(n<0)
{cp->ptr=(void*)SOAP\u NEW(struct ns\u GetRecord);
如果(尺寸)
*size=sizeof(struct ns\uu GetRecord);
}
其他的
{cp->ptr=(void*)SOAP_NEW_数组(struct ns_ugetrecord,n);//error=SOAP_EOM;
返回(struct ns_uugetrecord*)cp->ptr;
}

为什么
ns\uu GetRecord
被解释为一个结构,而它是一个函数名?我应该在TestServer.h中修复什么,使soapcpp2.exe生成一个可编译的代码?

我找到的唯一解决方案是删除
soap\u实例化ns\uu GetRecord
函数体

SOAP_FMAC1 struct ns__GetRecord * SOAP_FMAC2 soap_instantiate_ns__GetRecord(struct 
    soap *soap, int n, const char *type, const char *arrayType, size_t *size)
{
    return NULL;
}
然后服务器代码编译并正常工作

[BCC32 Error] soapC.cpp(1611): E2238 Multiple declaration for 'ns__GetRecord(soap *,int,Record *)'
[BCC32 Error] soapStub.h(224): E2344 Earlier declaration of 'ns__GetRecord(soap *,int,Record *)'
[BCC32 Error] soapC.cpp(1611): E2303 Type name expected
[BCC32 Error] soapC.cpp(1611): E2379 Statement missing ;
[BCC32 Error] soapC.cpp(1717): E2379 Statement missing ;
SOAP_FMAC5 int SOAP_FMAC6 ns__GetRecord(struct soap*, int id, Record *result);
SOAP_FMAC1 struct ns__GetRecord * SOAP_FMAC2 soap_instantiate_ns__GetRecord(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
{
    (void)type; (void)arrayType; /* appease -Wall -Werror */
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_ns__GetRecord(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
    struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_ns__GetRecord, n, soap_fdelete);
    if (!cp)
        return NULL;
    if (n < 0)
    {   cp->ptr = (void*)SOAP_NEW(struct ns__GetRecord);
        if (size)
            *size = sizeof(struct ns__GetRecord);
    }
    else
    {   cp->ptr = (void*)SOAP_NEW_ARRAY(struct ns__GetRecord, n); // <<<-- error here
        if (size)
            *size = n * sizeof(struct ns__GetRecord);
    }
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
    if (!cp->ptr)
        soap->error = SOAP_EOM;
    return (struct ns__GetRecord*)cp->ptr;
}
SOAP_FMAC1 struct ns__GetRecord * SOAP_FMAC2 soap_instantiate_ns__GetRecord(struct 
    soap *soap, int n, const char *type, const char *arrayType, size_t *size)
{
    return NULL;
}