2011-12-21 99 views
1

我正在處理.wsdl文件以定義gSOAP服務。在服務的請求中的一個,我想用一個用戶定義類型的請求的一部分,但我無法得到它的權利,不知道是什麼問題:C++ gSOAP wsdl類型

<definitions name="Uploader" 
    targetNamespace="http://192.168.2.113/uploader/uploader.wsdl" 
    xmlns:tns="http://192.168.2.113/uploader/uploader.wsdl" 
    [...]> 
[...] 
<types> 
    <schema targetNamespace="http://192.168.2.113/uploader/uploader.wsdl" 
     xmlns="http://www.w3.org/2001/XMLSchema"> 

     <element name="FileInformation"> 
      <complexType><all> 
       <element name="sFilename" type="string"/> 
       <element name="bDirectory" type="boolean"/> 
      </all></complexType> 
     </element> 

     [...] 

     <element name="UploadRequest"> 
      <complexType><all> 
       <element name="fileInfo" type="tns:FileInformation"/> 
      </all></complexType> 
     </element> 

     [...] 

    </schema> 
</types> 
[...] 
</definitions> 

當我嘗試產生出它與wsdl2h -o Uploader.h http://192.168.2.113/uploader/uploader.wsdlfileInfo成員將被定義爲一個字符串的頭文件,我得到以下警告:

Warning: could not find element 'fileInfo' type '"http://192.168.2.113/uploader/uploader.wsdl":FileInformation' in schema http://192.168.2.113/uploader/uploader.wsdl 

回答

1

我試着寫了幾WSDL文件我自己,但是我發現他們是非常難以正確使用,主要是因爲XML名稱空間,所以我建議您使用C++編寫類並生成WSDL文件auto從他們身上取而代之,而不是以相反的方式進行。

如果這是不可能的,我會建議看看這個thread。我認爲,如果你改變你的架構爲這樣的東西,它可能會工作:

<definitions name="Uploader" 
targetNamespace="http://192.168.2.113/uploader/uploader.wsdl" 
xmlns:tns="http://192.168.2.113/uploader/uploader.wsdl"> 

<types> 
    <schema targetNamespace="http://192.168.2.113/uploader/uploader.wsdl" 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 

     <xsd:element name="FileInformation" type="tns:FileInformation" /> 
     <xsd:complexType name="FileInformation"> 
      <xsd:all> 
       <xsd:element name="sFilename" type="string"/> 
       <xsd:element name="bDirectory" type="boolean"/> 
      </xsd:all> 
     </xsd:complexType> 

     <xsd:element name="UploadRequest" type="tns:UploadRequest"/> 
     <xsd:complexType name="UploadRequest"> 
      <xsd:all> 
       <xsd:element name="fileInfo" type="tns:FileInformation"/> 
      </xsd:all> 
     </xsd:complexType> 

    </schema> 
</types> 
</definitions> 
+0

完美,謝謝一堆。是的,我真的應該開始使用生成的文件。我想我會更好地理解SOAP,前提是我自己先做這樣的事情。 – nijansen 2011-12-21 14:12:19

+0

不客氣!我自己經歷過你的問題並相信我,編寫WSDL文件你的自我可能非常複雜...... – Felipe 2011-12-21 14:16:44