通过 .NET 与第三方 Web 服务通信
在当前项目中,我需要与 .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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果服务提供
.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 toolwsdl.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.