I've been handed some documentation about an API and been told to integrate it (the API uses SOAP). I'm familiar with web services and how they work, but I've never built a functional one. That is to say, I can create a basic web method in C# but I've never written开发者_Go百科 anything to connect to an external system.
I've read parts of books and I've not been able to find a good example about how to connect to and use a third-party API. I guess my question would be "how can I use this API with our systems?" Any help would be greatly appreciated, even if it's just pointing me to some good tutorials.
Basically you can just add a Web Reference to the API ('Add Service Reference' or 'Add Web Reference' depending on your version of Studio).
From there Studio will download the information it needs to build a proxy class which you can reference and use just like any object in your system.
var RemoteService = new RemoteAPI.APIMethods();
var result = RemoteService.Method1(foo, bar);
Here's a pretty good place to start for ASP.NET web services.
If you're using .NET 3.0 or higher, I suggest using WCF. If you decide to go that route, I highly suggest this book.
Here's a breakdown of Comparing ASP.NET Web Services to WCF Based on Development.
Hope that helps to get you started.
精彩评论