32

How to create web service (server & Client) in Visual Studio 2012? like being done before 2012 as http://www.tutorialspoint.com/asp.net/asp.net_web_services.htm

Sachin Warke
  • 549
  • 1
  • 5
  • 7
  • I'm voting to close this question as off-topic because I had asked the question when I had recently started my career and was using M.S. Visual Studio 2012; now latest version 2019 is available hence wanted to close this thread. – Sachin Warke Jun 20 '19 at 07:47
  • I also apologize for delayed reply to accept the answer; actually I had got the solution with my friends at that time but it was my bad that I didn't updated this thread, I was fresher and didn't know how to use these kind of forums. After that I had changed my role in my career and was not using development forums. I publicly apologize here and will take care of it in future. – Sachin Warke Jun 20 '19 at 07:51

4 Answers4

106

When creating a New Project, under the language of your choice, select Web and then change to .NET Framework 3.5 and you will get the option of creating an ASP.NET WEB Service Application.

enter image description here

philu
  • 795
  • 1
  • 8
  • 17
Adrian L.
  • 1,084
  • 1
  • 8
  • 2
32
  1. Create a new empty Asp.NET Web Application.
  2. Solution Explorer right click on the project root.
  3. Choose the menu item Add-> Web Service
olevegard
  • 5,294
  • 1
  • 25
  • 29
Vincenzo Costa
  • 930
  • 11
  • 17
  • This is the current method if not switching back to an older .NET framework. You can add a web service .asmx file to any ASP.NET project as a `New Item`. – atconway Nov 07 '13 at 18:46
  • 1
    tried, has not worked ( i have no web service in Add - neither in project nor solution) – Offler Jan 27 '14 at 13:17
  • 3
    Worked for me, by going to Add -> Class... -> Web Service – Patrick Feb 10 '14 at 16:37
  • Is it possible to create C++ web service in visual studio? –  Jul 16 '16 at 05:29
  • See https://msdn.microsoft.com/en-us/library/14hykb68(v=vs.80).aspx and http://stackoverflow.com/questions/6542676/web-services-in-c-and-c – Vincenzo Costa Jul 18 '16 at 16:34
12

WCF is a newer technology that is a viable alternative in many instances. ASP is great and works well, but I personally prefer WCF. And you can do it in .Net 4.5.

WCF Project

enter image description here

Create a new project. enter image description here Right-Click on the project in solution explorer, select "Add Service Reference" enter image description here

Create a textbox and button in the new application. Below is my click event for the button:

private void btnGo_Click(object sender, EventArgs e)
    {
        ServiceReference1.Service1Client testClient = new ServiceReference1.Service1Client();
        //Add error handling, null checks, etc...
        int iValue = int.Parse(txtInput.Text);
        string sResult = testClient.GetData(iValue).ToString();
        MessageBox.Show(sResult);
    }

And you're done. enter image description here

Aaron
  • 1,313
  • 16
  • 26
  • This was a great example and got me up and running quickly. Thanks! – Ken Cone Dec 30 '14 at 03:14
  • What you write is correct, but is out of the scope of the question. I had the same problem: need to rewrite a Web service that is consumed as an classic Web service, and cannot be updated to WCF as we do not control client side. – Robert Mar 04 '16 at 07:29
  • @Robert I don't see "Classic" or "ASP" in the title or question. I see "How to create web service (server & Client) in Visual Studio 2012?" I believe I also stated "viable alternative in many cases." Not *all* cases. It obviously didn't meet your needs, but you are not on an ASP tagged post. You are on a web services tagged post. This is a web service. Your point is noted, but I must disagree. – Aaron Apr 27 '16 at 13:50
2

--- create a ws server vs2012 upd 3

  1. new project

  2. choose .net framework 3.5

  3. asp.net web service application

  4. right click on the project root

  5. choose add service reference

  6. choose wsdl

--- how can I create a ws client from a wsdl file?

I´ve a ws server Axis2 under tomcat 7 and I want to test the compatibility

PhatHV
  • 8,010
  • 6
  • 31
  • 40