如何在Windows 8.1应用程序和Windows Phone 8应用程序中使用SOAP? [英] How to use SOAP in Windows 8.1 apps and in Windows Phone 8 apps?

查看:104
本文介绍了如何在Windows 8.1应用程序和Windows Phone 8应用程序中使用SOAP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一些方法可以在.net-4.5中创建SOAP请求并获得SOAP响应?

解决方案

您可以通过以下位置的添加服务引用功能使用SOAP服务:

解决方案

视觉工作室。在后台,这将调用 svcutil .wsdl 转换为 .cs 服务原型。



.Net框架包括WCF(这是较新的和推荐的网络通信框架)以及.Net Remoting(这是与某些非.Net SOAP端点更加兼容。



请参见





示例



用于位于 http://www.webservicex .net / currencyconvertor.asmx?WSDL :




  • 生成客户端代理
    svcutil http://www.webservicex.net/currencyconvertor.asmx?WSDL

  • 重命名生成的配置
    移动输出。 config program.exe.config

  • 创建测试客户端:



Program.cs

 使用系统; 
使用www.webservicex.net;

类程序
{
public static void Main(string [] args)
{
var client = new CurrencyConvertorSoapClient( CurrencyConvertorSoap);
var conv = client.ConversionRate(Currency.USD,Currency.EUR);
Console.WriteLine(从USD到EUR的转换率为{0},转换);
}
}




  • 编译
    csc Program.cs CurrencyConvertor.cs

  • 运行:
    c:\Drop\ \soaptest> Program.exe
    从美元到欧元的转换率是0.7221


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?

解决方案

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.

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.

See

Example

For the service located at http://www.webservicex.net/currencyconvertor.asmx?WSDL:

  • Generate the client proxy
    svcutil http://www.webservicex.net/currencyconvertor.asmx?WSDL
  • Rename the config produced
    move output.config program.exe.config
  • Create a test client:

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);
    }
}

  • Compile
    csc Program.cs CurrencyConvertor.cs
  • Run:
    c:\Drop\soaptest>Program.exe
    Conversion rate from USD to EUR is 0.7221

这篇关于如何在Windows 8.1应用程序和Windows Phone 8应用程序中使用SOAP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆