How to Get an API Stream in XML Format

An application programming interface lets programmers connect to remote servers and run functions set up by the API developers. You must use the .NET SOAP messaging service to connect to the XML servers from your Web app. SOAP is formatted in XML so the response from the SOAP message is parsed with internal .NET functions. The .NET language automatically parses the XML message so all you must do is make a connection to the API.

Instructions

    • 1

      Open Visual Studio from the Windows "Start" menu. Open your Web application you want to use to connect to the API.

    • 2

      Double-click the file you want to use to connect to the API. The .NET code file opens to the code editor. Add the SOAP libraries to the top of the file. Copy and paste the following code to the top of the file:

      using Microsoft.Web.Services2;
      using Microsoft.Web.Services2.Messaging;
      using Microsoft.Web.Services2.Addressing;

    • 3

      Make a request to the SOAP server. The following code opens the API on the remote server using the XML SOAP format:

      SoapEnvelope call = new SoapEnvelope("API Service", envelope);

      Replace "API Service" with the name of the API to which you want to connect.

    • 4

      Get the XML response from the server. The "SoapEnvelope" class stores the response from the API in the XML format. Use the following code to retrieve the server response:

      SoapEnvelope return = client.RequestResponseMethod(call);

Related Searches:

References

Comments

Related Ads

Featured