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
其实我解决了这个问题。问题在于使用。我需要发布带有XSD模式的wsdl2h可执行文件作为参数,而不是XML文件。这修复了所有的错误(我只在Windows 64位Vista上测试过)。谢谢。 – 2011-12-18 04:26:51