2011-12-17 92 views
0

它看起來像gSoap「忘記」生成很多東西。我用C++ gSOAP文件生成

wsdl2h.exe -o NumOpsService.h http://192.168.2.113/numops.wsdl 
soapcpp2.exe -x -l -I..\..\import -C NumOpsService.h 

而且兩個都沒有錯誤或警告貫穿始終。當我將這些文件包含到我的項目中時,結果發現在soapH.h中聲明瞭幾個函數,但是應該位於soapC.cpp中的相應實現缺失。

以下功能缺失:

SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int); 
SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int); 
SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*); 
SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap*); 
SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*); 
SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*); 
SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*); 
SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*); 
SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*); 
SOAP_FMAC3 void* SOAP_FMAC4 soap_container_id_forward(struct soap*, const char*, void*, size_t, int, int, size_t, unsigned int); 
SOAP_FMAC3 void SOAP_FMAC4 soap_container_insert(struct soap*, int, int, void*, size_t, const void*, size_t); 

怎麼能這樣呢?這是numops.wsdl文件的問題嗎?我使用生成文件看起來是這樣的:

<definitions name="NumOps" 
    targetNamespace="http://192.168.2.113/numops.wsdl" 
    xmlns:tns="http://192.168.2.113/numops.wsdl" 
    xmlns:xsd1="http://192.168.2.113/testtypes.xsd" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns="http://schemas.xmlsoap.org/wsdl/"> 

<types> 
    <schema targetNamespace="http://192.168.2.113/testtypes.xsd" 
     xmlns="http://www.w3.org/2001/XMLSchema"> 
     <element name="AddValRequest"> 
      <complexType> 
       <all> 
        <element name="fVal1" type="float"/> 
        <element name="fVal2" type="float"/> 
       </all> 
      </complexType> 
     </element> 
     <element name="AddValResponse"> 
      <complexType> 
       <all> 
        <element name="fResult" type="float"/> 
       </all> 
      </complexType> 
     </element> 
    </schema> 
</types> 

<message name="AddValInput"> 
    <part name="body" element="xsd1:AddValRequest"/> 
</message> 
<message name="AddValOutput"> 
    <part name="body" element="xsd1:AddValResponse"/> 
</message> 

<portType name="NumOpsPortType"> 
    <operation name="AddVal"> 
     <input message="tns:AddValInput"/> 
     <output message="tns:AddValOutput"/> 
    </operation> 
</portType> 

<binding name="NumOpsSoapProxy" type="tns:NumOpsPortType"> 
    <soap:binding style="document" 
     transport="http://schemas.xmlsoap.org/soap/http"/> 
    <operation name="AddVal"> 
     <soap:operation soapAction="http://192.168.2.113/index.php"/> 
     <input> 
      <soap:body use="literal"/> 
     </input> 
     <output> 
      <soap:body use="literal"/> 
     </output> 
    </operation> 
</binding> 

<service name="NumOpsService"> 
    <port name="NumOpsPort" binding="tns:NumOpsSoapProxy"> 
     <soap:address location="http://192.168.2.113/index.php"/> 
    </port> 
</service> 

</definitions> 

我是新來gSOAP的,文檔不幸的是,沒有過度,並在互聯網上沒有人好像之前有過這個問題,也許我正在尋找錯誤的方向。

我已將生成的所有文件(除NumOpsService.h)都包含到我的項目中,並且還添加了stdsoap2.hstdsoap2.cpp。因爲丟失的功能不會編譯源代碼如下所示:

#include <stdio.h> 
#include "NumOpsSoapProxy.nsmap" 
#include "soapNumOpsSoapProxyProxy.h" 

int main() { 
    NumOpsSoapProxy proxy; 
    _ns2__AddValRequest request; 
    _ns2__AddValResponse response; 

    request.fVal1 = 10; 
    request.fVal2 = 20; 

    if(proxy.__ns1__AddVal(&request, &response) == SOAP_OK) { 
     printf("%d + %d = %d\n", request.fVal1, request.fVal2, response.fResult); 
    } 
    else { 
     printf("Request failed.\n"); 
    } 
} 
+2

在您的soapcpp2命令行中,我認爲使用了-l,這個生成可鏈接模塊的字母(實驗性)是否實際上是指使用-1(數字)來使用SOAP 1.1名稱空間和編碼? – Jackson 2011-12-17 14:33:22

回答

3

我的評論提升到一個答案:

在你soapcpp2命令行中你已經使用-l,信, 當您應該使用-1 (數字)來使用SOAP 1.1命名空間和編碼時,它會生成可鏈接的模塊(實驗)。