2011-12-13 152 views
0

我想用gsoap將一些XML數據加載到C++代碼(類)中。他們在文檔中提供的示例中討論瞭如何將Web服務文檔加載到C++頭文件(wsdl2h)中;但沒有直接使用XML文件的明確例子。不管怎麼說,我安裝gSOAP的(使用預編譯的二進制文件),並試圖作爲第一步,這樣做的:gsoap用XML數據生成C++代碼

wsld2h -o <myexample_cpp.h> <myexample.xml> 

和我:

../../bin/linux386/wsdl2h: ../../bin/linux386/wsdl2h: cannot execute binary file 

作爲最後一個音符,我在Cygwin的測試此(使用linux二進制文件),但我懷疑這可能會導致任何錯誤。另外我想知道XML文件是否必須具有「xml」擴展才能使其工作?感謝有任何想法的人可以分享他們的經驗。

編輯: 其實這可能是由於在cygwin上運行linux預編譯的二進制文件。無論如何,我想這從Windows命令行,而不是和我有什麼似乎是一個合法的錯誤:

<path/to>\tests\gsoap>..\..\bin\win32\wsdl2h.exe -o myexample_soap_cpp.h myexample.xml 

    ** The gSOAP WSDL/Schema processor for C and C++, wsdl2h release 2.8.5 
    ** Copyright (C) 2000-2011 Robert van Engelen, Genivia Inc. 
    ** All Rights Reserved. This product is provided "as is", without any warranty. 
    ** The wsdl2h tool is released under one of the following two licenses: 
    ** GPL or the commercial license by Genivia Inc. Use option -l for details. 

    Saving myexample_soap_cpp.h 

    Cannot open file 'typemap.dat' 
    Problem reading type map file 'typemap.dat'. 
    Using internal type definitions for C++ instead. 


    Reading file 'myexample.xml'... 

    An error occurred while parsing WSDL or XSD from 'myexample.xml' 
    Error 3 fault: SOAP-ENV:Client [no subcode] 
    "Validation constraint violation: tag name or namespace mismatch in element 'ns4:xmlDocument'" 
    Detail: [no detail] 
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
    <ns4:xmlDocument xmlns="http://purl.org/dc/terms/" xmlns:ns2="http://www.w3.org/1999/xlink" xmlns:ns3="http://www.opengis.net/gml/3.2" xmlns:ns4="h 
    /www.isotc211.org/2005/gmd" xmlns:ns7="http://www.<my_website>" version="1.1.0.0(XML)"> 
<title>myexample</title> 
<creator>l0352955</creator> 
<publisher>blah</publisher> 
<created xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="W3CDTF">2011-07-25T10:43:26.622+02:00</created> 
<format>XML/HDF</format> 
<ns4:areaOfInterest ns3:id="AreaOfInterest"> 
    <ns3:description>Some description</ns3:description> 
    <ns3:boundedBy> 
     <ns3:Envelope> 
      <ns3:lowerCorner>427875.13794 6736113.80757</ns3:lowerCorner> 
      <ns3:upperCorner>436165.54057 6747905.74672</ns3:upperCorner> 
     </ns3:Envelope> 
    </ns3:boundedBy> 
    <ns4:outline> 
     <ns3:SomeShape ns3:id="ShapeOfInterest"> 
      <ns3:exterior> 
       <ns3:Linear> 
        <ns3:pos>431960.26388 6736113.80757</ns3:pos> 
        <ns3:pos>436165.54057 6737898.90462</ns3:pos> 
        <ns3:pos>431960.26388 
+1

其實我解決了這個問題。問題在於使用。我需要發佈帶有XSD模式的wsdl2h可執行文件作爲參數,而不是XML文件。這修復了所有的錯誤(我只在Windows 64位Vista上測試過)。謝謝。 – 2011-12-18 04:26:51

回答

0

其實,我解決了這個。問題在於使用。我需要發佈帶有XSD模式的wsdl2h可執行文件作爲參數,而不是XML文件。這修復了所有的錯誤(我只在Windows 64位Vista上測試過)。謝謝。