通过 .NET 与第三方 Web 服务通信

发布于 2024-11-19 17:16:09 字数 202 浏览 5 评论 0原文

在当前项目中,我需要与 .NET 的第三方 Web 服务进行通信。困难的部分是构造 SOAP 消息并将其发布到服务器。经过足够的谷歌搜索后,我发现通过使用 SoapClient 类,我可以轻松地构造/发送/接收肥皂消息,但我认为为此我必须添加对 WSE 程序集的引用,而且它有点过时了。

在这种情况下使用 SoapClient 是正确的方法还是 WCF 中有其他更好的方法?

In the current project I need to communicate with third-party web services from .NET. The difficult part is constructing SOAP messages and posting to the server. After googling enough I found by using SoapClient class I can easily construct/send/receive soap message but I think for that I've to add references to WSE assemblies and it is kind of obsolete.

Is it the right way to use SoapClient for this scenario or any other better ways there in WCF?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独自←快乐 2024-11-26 17:16:09

如果服务提供 .wsdl 文件,您可以让 VS 通过添加服务引用来生成强类型代理/包装类(这是使用命令行工具 wsdl 完成的)。 exe)。在 Visual Studio 中右键单击您的项目,然后选择“添加服务引用...”,然后输入 .wsdl 文件的 URL。 “添加服务引用...”将生成具有与 Web 服务定义中定义的方法相对应的方法以及强类型请求和响应类型的客户端类。代理可以配置为允许同步和异步方法调用。

有关更多详细信息,请参阅这篇 MSDN 文章

If the service provides a .wsdl file, you can have VS generate strongly-typed proxy/wrapper classes for you by adding a service reference (this is done using the command-line tool wsdl.exe). Right-click on your project in Visual Studio and select "Add Service Reference..." and enter the URL of the .wsdl file. "Add Service Reference..." will generate client classes with methods and strongly-typed request and response types corresponding to the methods defined in the web service definition. The proxies can be configured to allow both synchronous and asynchronous method invocation.

See this MSDN article for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文