Creating a web service client - where to start? RRS feed

  • General discussion

  • I need to build a web service client that connects to a web service API. The webservice client program would use a toolkit that knows how to connect and interact with web services. I'm going to use SOAP as toolkit. Also I'm using "Visual Studio Express 2013 Preview for web".

    1. Do SOAP already comes with "Visual Studio Express 2013 Preview for web" or will it be a separate install?
    2. Is there any tutorial that is pretty close to what I'm about to do?

    I want to use C# and I wonder where do I start when creating a new project? What kind of project template would be the most suitable?

    I figure maybe I should go with Templates->Visual C#->web->ASP.NET Web Application


    Or maybe some other template:


    Friday, August 16, 2013 3:38 AM

All replies

  • Hi Jonas,

    You can consume the web service in any types of project like Console Application, Windows Form Application, Web Application, WPF Application, SilverLight Application, Windows 8 Store Application etc...

    WCF Service can return data in three formats like SOAP, POX(Plain Old XML) and JSON. This behavior is controlled from WCF service and nothing can be done from Client side. At Client side, you can get data in defined format and serialized the data as per your need using XMLSerializer, JSONSerializer etc.

    You have to create any types of project(web or windows) and Add the service URL using "Add Service Reference". The proxy class can automatically be created and you can access the proxy classes from your code.

    Another way is to run svcutil.exe with the service url and proxy classes will be generated. You can add proxy class in your project and start calling the service.

    Subhendu DE - Visit My Blog If a post answers your question, please click Mark As Answer on that post. If you find a post helpful, please click Vote as Helpful.

    Friday, August 16, 2013 9:45 AM
  • OK thanks, I got a little wiser.

    How do I know if the web service I'm gonna consume is a WCF Service? It doesn't say anything about that in the documentation I got, only that it is a Web Service API and the URL to connect is basically:

    I created an "ASP.NET Empty Web Application" and tried the first option "Add Service Reference", but I don't see any Proxy classes showing up. How come? Shoudn't they be automatically created?

    The only thing that is showing up in object browser is this:


    And In Solution Explorer I have this:


    Saturday, August 17, 2013 2:51 AM
  • Hi Jonas,

    You can turn on "Show All Files" from Solution Explorer and then look for Reference.cs

    Subhendu DE - Visit My Blog If a post answers your question, please click Mark As Answer on that post. If you find a post helpful, please click Vote as Helpful.

    Saturday, August 17, 2013 5:45 AM
  • OK thanks, that did the work. Excellent! Thanks for all the clear explanations.

    So it looks like in this Reference.cs all the XML code are translated in to methods I can use? Is that how it works?

    There is this other part I would need help with just to get started, then I will try to Google and do a little search on my own as much as possible.

    Also I got a username and password from the web service supplier, so I need to set them as well as they show in the document I received:

    PartnerInfoService pbs = new PartnerInfoService();
    pbs.Credentials = new NetworkCredential("usr","pwd");

    Also mention in this document is:

    "The credentials must be set before you call any of the methods of the web service. If you do not set the credentials, you will receive the error code HTTP 401 Error: Access Denied. You must authenticate the service before you use it, but after you have set the credentials, you do not need to set them again as long as you continue to use the same service variable (such as pbs in the above example)."

    So where can I set this credentials? Do I create a separate class and set them there before calling any of the methods?

    Sunday, August 18, 2013 6:19 AM