如何在 Windows 8.1 应用程序和 Windows Phone 8 应用程序中使用 SOAP? [英] How to use SOAP in Windows 8.1 apps and in Windows Phone 8 apps?
问题描述
是否有一些方法可以在 .net-4.5 中创建 SOAP 请求和获取 SOAP 响应?如果有必要,我应该安装哪些扩展?
Is there some methods to create SOAP-requests and to get SOAP-responses in .net-4.5? Which extentions I should to install, if it's necessary?
推荐答案
您可以通过 Visual Studio 中的添加服务引用"功能使用 SOAP 服务.在幕后,这将调用 svcutil
将 .wsdl
转换为 .cs
服务原型.
You can use SOAP services via the "Add Service Reference" function in Visual Studio. Behind the scenes, this will call svcutil
to convert the .wsdl
into .cs
service prototypes.
.Net Framework 包括 WCF,这是较新的和推荐的网络通信框架,以及 .Net Remoting,它与一些非 .Net SOAP 端点更兼容.
The .Net Framework includes both WCF, which is the newer and recommended network communication framework, as well as .Net Remoting, which is more compatible with some non-.Net SOAP endpoints.
见
- WCF 简介 (MSDN)
- 此答案从 SOAP 角度解决 WCF 的类似问题
- 演练:创建和访问 WCF 服务 (MSDN)
- WCF 中的 WSDL URI 是什么?
- 将自定义 [SOAP]
MessageHeader
添加到 WCF 调用(MSDN 博客)
- Introduction to WCF (MSDN)
- This answer to a similar question addressing WCF from a SOAP perspective
- Walkthrough: Creating and accessing WCF Services (MSDN)
- what is WSDL URI in WCF?
- Adding Custom [SOAP]
MessageHeader
s to a WCF Call (MSDN Blog)
对于位于 http://www.webservicex.net/currencyconvertor.asmx?WSDL:
- 生成客户端代理
svcutil http://www.webservicex.net/currencyconvertor.asmx?WSDL
- 重命名生成的配置
move output.config program.exe.config
- 创建一个测试客户端:
Program.cs:
using System;
using www.webservicex.net;
class Program
{
public static void Main(string[] args)
{
var client = new CurrencyConvertorSoapClient("CurrencyConvertorSoap");
var conv = client.ConversionRate(Currency.USD, Currency.EUR);
Console.WriteLine("Conversion rate from USD to EUR is {0}", conv);
}
}
- 编译
csc Program.cs CurrencyConvertor.cs
- 运行:
c:Dropsoaptest>Program.exe
从美元到欧元的转换率为 0.7221
这篇关于如何在 Windows 8.1 应用程序和 Windows Phone 8 应用程序中使用 SOAP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!