从 C++ 调用 Web 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4863447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 16:48:28  来源:igfitidea点击:

Calling a web service from C++

c++web-servicesclient

提问by Jan Doerrenhaus

I have a simple web service running on a JBoss server. Now I need to access it from C++, Microsoft VC++ 2010, to be precise. Being new to web services in general, I googled my problem, but found that most people advised to to "Add Web Reference", something that appears to be gone since VS2008. So I was wondering if somebody could give me a few pointers on what the easiest way to call a web service from C++ would be.

我在 JBoss 服务器上运行了一个简单的 Web 服务。现在我需要从 C++、Microsoft VC++ 2010 中访问它,准确地说。作为 Web 服务的新手,我在 google 上搜索了我的问题,但发现大多数人建议“添加 Web 引用”,这似乎自 VS2008 以来就消失了。所以我想知道是否有人可以给我一些关于从 C++ 调用 Web 服务的最简单方法的指示。

Thanks in advance for your time.

在此先感谢您的时间。

采纳答案by DesignFirst

you can try gSoap

你可以试试gSoap

回答by Dennis

I also recommend gSOAP. It can be a handful but it works. Point it at a WSDL and it'll generate proxies that you can use in your client code.

我也推荐 gSOAP。它可以是少数,但它有效。将其指向 WSDL,它将生成您可以在客户端代码中使用的代理。

It's free if you are producing open source work as well.

如果您也在制作开源作品,它也是免费的。

回答by Andy

I used the sproxy tool to generate a C++/ATL header file for my web service. The sproxy tool comes with the ATL Server source code (CodePlex). Although the project's been dead for a few years so I had to do the work of manually converting the project to VS2010 (it wouldn't convert automatically using the conversion wizard), but now it works and I was able to call my web service from a console app with just a few lines of code.

我使用 sproxy 工具为我的 Web 服务生成 C++/ATL 头文件。sproxy 工具随 ATL Server 源代码 (CodePlex) 一起提供。虽然该项目已经死了几年,所以我不得不手动将项目转换为 VS2010(它不会使用转换向导自动转换),但现在它可以工作了,我可以从只需几行代码的控制台应用程序。