将 vmware web api 客户端代码编译为可用对象时出现问题
我正在使用 vmware 的 Web application api 来尝试简单地检索“ServiceContent”对象中的字段。 vmware 论坛 上有一个如何完成此操作的示例。那里包含的示例对我来说编译得很好,但是在运行简单示例时我遇到了段错误 - 特别是跟踪返回到soap_serializeheader()函数(我相信这些是在stdsoap2.cpp中定义的)。 我的问题是,我不知道如何避免这种段错误,也不知道为什么会发生这种情况(因为我几乎逐字逐句地遵循该示例)。我正在使用 OS X 工具链(gcc 版本 4.0.1(Apple Inc. build 5465))与(gsoap 版本 2.7.16)相结合。我尝试了 gsoap 2.8 但得到了相同的结果。以下是我到达现在位置的过程。
这些是我用来解析 wsdl 的命令:
wsdl2h -o vim25.h vimService.wsdl
解析后,我使用以下命令进行编译:
soapcpp2 -x -C -pvsp vim25.h -I/place/where/stlvector.h/is
这会生成文件 vspC.cpp、vspClient.cpp 和 vspVimBindingProxy.cpp。在内部,这些文件具有相同的函数前缀(即 ns1/ns2 等),因此我的调用与示例中的调用相同。
这是我用来编译 vspC.cpp 和 vspClient.cpp 的命令:
g++ -DWITH_COOKIES -DWITH_OPENSSL -c vspC.cpp
g++ -DWITH_COOKIES -DWITH_OPENSSL -c vspClient.cpp
这是我用来编译 stdsoap2.cpp 的命令(如果我不使用 -DWITH_NONAMESPACES 进行编译,当我链接所有内容):
g++ -DWITH_COOKIES -DWITH_OPENSSL -DWITH_NONAMESPACES -c stdsoap2.cpp
然后我将所有内容与测试代码链接在一起(这也是从示例中几乎完全相同地复制的,只是进行了更改以正确引用我创建的文件):
g++ -DWITH_COOKIES -DWITH_OPENSSL vspC.o vcpClient.o stdsoap2.o testcase.cpp -lssl -lcrypto -o doesntwork
这可以正确编译,但当然无法运行。我在 vmware 论坛帖子中了解到一位 OS X 用户也遇到了问题。它出现 gsoap 指南说不能使用stdsoap2.cpp的头和错误序列化代码,必须单独编译它们。 OS X 帖子中的用户似乎已经这样做了,但是我不确定如何合并它们进入我的测试文件(他创建空的 env.h 文件,然后用soap2cpp 编译它) - 如果我包含 envH.h 文件,我会遇到与 vspH.h 的命名冲突。 所以第二个问题是如何使用soap2cpp正确编译所有存根,以免出现命名空间冲突(这就是我遇到的情况)。
我不会提供来源,因为它显示在用户 Stumpr 的第一个 vwmare 论坛链接上。我不相信问题出在源代码中,而是问题出在我在使用 g++ 编译期间使用 wsdl2h、soap2cpp 或一些不正确的标志组合的方式。
感谢看了一下,希望有人能解决这个问题!
编辑 我想我可能已经解决了这个问题 - 通过使用 64 位系统(以及具有更多内存的系统)。我尝试在 X.6 上使用 -m32 进行编译,但无法完成(抱怨内存问题)。
希望有人会偶然发现这一点并很高兴知道答案。
I'm using vmware's web application api in an attempt just to simply retrieve the fields in the "ServiceContent" object. There is an example of how this should be accomplished located at the vmware forum. The example contained there compiles fine for me however I get segfaults when running the simple example - specifically the trace goes back to the soap_serializeheader() function (I believe these are defined in stdsoap2.cpp). My problem is that I do not know how to avoid this segfault and have no idea why this is occurring (as I am following the example almost word for word). I am using OS X tool chain (gcc version 4.0.1 (Apple Inc. build 5465) ) combined with (gsoap release 2.7.16). I tried gsoap 2.8 but got the same result. Below is the procedure I used to get to where I am now.
These are the commands I used to parse the wsdl:
wsdl2h -o vim25.h vimService.wsdl
Once this is parsed, I compiled using the following command:
soapcpp2 -x -C -pvsp vim25.h -I/place/where/stlvector.h/is
this generates files vspC.cpp, vspClient.cpp, and vspVimBindingProxy.cpp. Internally these files have the same prefixes for functions (i.e. ns1/ns2 etc) so my calls are the same as those in the example.
This is the command I am using to compile vspC.cpp and vspClient.cpp:
g++ -DWITH_COOKIES -DWITH_OPENSSL -c vspC.cpp
g++ -DWITH_COOKIES -DWITH_OPENSSL -c vspClient.cpp
This is the command I use to compile stdsoap2.cpp (if I do not compile with -DWITH_NONAMESPACES I get an error about an undefined symbol "_namepspaces" when I link everything):
g++ -DWITH_COOKIES -DWITH_OPENSSL -DWITH_NONAMESPACES -c stdsoap2.cpp
I then link everything together with the test code (again this is copied almost identically from the example, just with the changes to correctly refer to the files I created):
g++ -DWITH_COOKIES -DWITH_OPENSSL vspC.o vcpClient.o stdsoap2.o testcase.cpp -lssl -lcrypto -o doesntwork
This compiles correctly, but of course fails to run. I read about an OS X user in this vmware forum post who was also having trouble. It appears the gsoap guide says you cannot use stdsoap2.cpp's header and fault serialization codes, and you must compile them separately. The user in the OS X post seems to have done this, however I am not sure how to incorporate them into my test file (he creates the empty env.h file and then compiles it with soap2cpp) - if I include the envH.h file i get about naming conflicts with vspH.h. So a second question would be how do I use soap2cpp to compile all the stubs correctly so that there are not namespace conflicts (which is what I appear to be encountering).
I will not provide the source, as it is displayed at the first vwmare forum link by user stumpr. I do not believe the issue is in the source, but in the way I have used either wsdl2h, soap2cpp, or some incorrect combination of flags during compilation with g++.
Thanks for taking a look, and hopefully some one can resolve the issue!
EDIT I think I may have solved this - by using a 64bit system (and one with more memory). I tried compiling with -m32 on the X.6 and it was not able to do it (complaining about memory issues).
Hopefully someone will stumble upon this and be happy to know the answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论