0

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?

splash27
  • 2,057
  • 6
  • 26
  • 49
  • Have also a look at Web.API http://www.asp.net/web-api for building RESTful services. – gsharp Apr 17 '14 at 07:04
  • Afaik, SOAP ASP.NET Webservices have been obsolete since .NET Framework 3.5 :) I advise - move on with the world. WCF is the way to go nowadays (speaking strictly .NET here) – Eon Apr 17 '14 at 13:47
  • @Noobgrammer, WCF uses SOAP by default – Mitch Apr 17 '14 at 14:01

1 Answers1

2

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
Community
  • 1
  • 1
Mitch
  • 21,223
  • 6
  • 63
  • 86
  • Too hard... Can you give a simple code example, how to create a request to server and how to read server's response? – splash27 Apr 17 '14 at 08:26
  • 1
    You are asking how to communicate with one of the most complicated standards in existence... it is not an easy one-liner. The introduction linked is quite complete in how to communicate with the server. – Mitch Apr 17 '14 at 13:27