SOAP API in Visual Studio in C#

To create a api there are alot opporunities. Right now I prefer SOAP-APIs in Visual Studio because it is easy as possible to create such one.

I will do this with Visual Studio 2017 and a console-application, so nothing special:

For the example I googled for free SOAP-Webservice and got this one here that can handle some information about the BLZ:

http://www.thomas-bayer.com/axis2/services/BLZService?wsdl

To start in Visual Studio I add a reference like this:

  1. Rightclick in the solution explorer at references.
  2. Click “Add Service Reference”
  3. Click “Advanced…”
  4. Click “Add Web Reference…”
  5. Paste the URL and click on the arrow.
  6. Type in a name that specifies the webservice-name in your project.
  7. Click “Add Reference”.
  8. Done!

<

pre>This will add a folder to your projects called “Web References” and will add the service. Like this you will also get every object and method that you need. So I am able to write this code:

var BLZService = new OpenSOAPBLZService.BLZService();
 var Bank = BLZService.getBank("10070100");
 Console.WriteLine(Bank.bezeichnung + " - " + Bank.ort);
 Console.ReadLine();

 

Here we create a new object based on the service that we created, create a new bank object (which class is also created by the Add-Reference-Function) and show the bank description and the location of the bank in the console. So we get this out here:

Advertisements