简体   繁体   English

gsoap与XML数据生成C ++代码

[英]gsoap with XML data to generate C++ code

I am trying to load some XML data into C++ code (classes) using gsoap. 我正在尝试使用gsoap将一些XML数据加载到C ++代码(类)中。 In the examples they have in the documentation they talk about loading web services documents to C++ headers (wsdl2h); 在文档中的示例中,他们讨论了将Web服务文档加载到C ++标头(wsdl2h); but there were no explicit examples using XML files directly. 但是没有直接使用XML文件的明确示例。 Anyways, I installed gsoap (using pre-compiled binaries) and tried as a first step, doing: 无论如何,我安装了gsoap(使用预编译的二进制文件)并尝试作为第一步,这样做:

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

and I got: 我得到:

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

As a last note, I am testing this in Cygwin (using the linux binary), but I doubt that might contribute to any error. 最后一点,我正在Cygwin(使用linux二进制文件)中对此进行测试,但是我怀疑这可能会导致任何错误。 Also I wanted to know if the XML file has to have the "xml" extension in order for it to work? 我也想知道XML文件是否必须具有“ xml”扩展名才能正常工作? Appreciate if anyone with some ideas can share their experiences. 感谢有想法的任何人都可以分享他们的经验。

Edit: Actually this could be due to running the linux pre-compiled binary on cygwin. 编辑:实际上,这可能是由于在cygwin上运行了Linux预编译的二进制文件。 Anyway I tried this from the Windows command line instead and I got what appears to be a legitimate error: 无论如何,我改用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

Actually, I resolved this. 实际上,我解决了这个问题。 The problem was the usage. 问题是用法。 I need to be issuing the wsdl2h executable with the XSD schemas as argument, not the XML files. 我需要使用XSD架构而不是XML文件发布wsdl2h可执行文件。 That fixes all the errors (I tested this only on Windows 64 bit Vista). 修复了所有错误(我仅在Windows 64位Vista上对此进行了测试)。 Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM