Using VS 2010. My Web Service is working fine. But while 'Consuming' from a 'Windows Forms Application', it fails..! Prolem started after I installed VS 2010 SP1. I have uninstalled the VS2010 SP1, VS2010 and VS Web Developer 2010 and Reinstalled all (without
the VS 2010 SP1..!)
This is the following Error Message I get while 'Add Web Reference' --> 'Go' ( Err:
This program cannot display the webpage)
Most likely causes:
You are not connected to the Internet.
The website is encountering problems.
There might be a typing error in the address.
Web Services Found at this URL:
There was an error downloading 'http://localhost:1451/Service1.asmx'.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:1451
There was an error downloading 'http://localhost:1451/Service1.asmx/$metadata'.
Unable to connect
--- Please help me what is wrong or changes I need to do.
From my 'Windows Forms Application' , I am referencing this (as per the Book !!) now I can open my IIS (Start --> Run --> inetmgr). Now pl. explain how to host this URL?
I installed VS 2010 Ultimate and SQL Server 2008 R in this same XP Professional Machine. I have IIS 5.1 running. So the above link for adding Web Site does not work or may be has to be done in different way.
I have added the following link to the IIS 5.1 --> "Home Directory" Tab --> Application Name
C:\Project Workplace\ASP.NET Web Services\AddNumbers\AddNumbers\Service1.asmx
Restarted the IIS and Ran the application .. did not work,
Then I put C:\Project Workplace\ASP.NET Web Services\AddNumbers\WebClient\Form1.cs
in the IIS 5.1 --> "Home Directory" Tab --> Application Name
Restarted the IIS and Ran the application .. STILL did not work,
My Client Application in in the same Project of the the "Seb Service" it can Reference the Web Service "Discovery" button.
But While Run time it only shows the following Error:-
Directory Listing -- /
Tuesday, February 07, 2012 09:30 AM <dir> App_Data
Friday, February 10, 2012 12:32 PM <dir> bin
Tuesday, February 07, 2012 09:30 AM <dir> obj
Tuesday, February 07, 2012 09:30 AM <dir> Properties
Wednesday, February 08, 2012 11:06 PM 4,068 AddNumbers.csproj
Wednesday, February 08, 2012 11:06 PM 1,086 AddNumbers.csproj.user
Thursday, February 09, 2012 02:26 PM 58 AddNumbers.Publish.xml
Tuesday, February 07, 2012 09:30 AM 92 Service1.asmx
Thursday, February 09, 2012 10:55 AM 816 Service1.asmx.cs
Tuesday, February 07, 2012 09:30 AM 7,543 Web.config
Tuesday, February 07, 2012 09:30 AM 1,285 Web.Debug.config
Tuesday, February 07, 2012 09:30 AM 1,346 Web.Release.config
BTW: WebMethod is as follows:-
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public Decimal add(Decimal a, Decimal b)
{
Decimal dc;
dc = a + b;
return dc;
}
}
N.B. When I Run the Add() Web Service, I must have to keep the "Cursor" of the First Line i.e. front of
using System; using System.Collections.Generic;
Otherwise I get above "Directory Listing " Error.. If I put my Cursot on the Code page, the Web Service Runs alone. But Calling From Client Never Works (After Consuming From Client application)
My Client Call:-
private void button1_Click(object sender, EventArgs e)
{
Decimal a, b, result;
var client = new WebClientRef.Service1();
a = Convert.ToDecimal(textBox1.Text);
b = Convert.ToDecimal(textBox2.Text);
result = client.add(a, b);
MessageBox.Show("The Total of :" + Convert.ToString(result));
}
nil68
Member
20 Points
12 Posts
'Consuming' a Web Service from a 'Windows Forms Application' fails..!
Feb 09, 2012 06:59 PM|LINK
Using VS 2010. My Web Service is working fine. But while 'Consuming' from a 'Windows Forms Application', it fails..! Prolem started after I installed VS 2010 SP1. I have uninstalled the VS2010 SP1, VS2010 and VS Web Developer 2010 and Reinstalled all (without the VS 2010 SP1..!)
This is the following Error Message I get while 'Add Web Reference' --> 'Go' ( Err:
This program cannot display the webpage)
Most likely causes:
Web Services Found at this URL:
There was an error downloading 'http://localhost:1451/Service1.asmx'.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:1451
There was an error downloading 'http://localhost:1451/Service1.asmx/$metadata'.
Unable to connect
--- Please help me what is wrong or changes I need to do.
kushalrdalal
Contributor
7130 Points
1273 Posts
Re: 'Consuming' a Web Service from a 'Windows Forms Application' fails..!
Feb 09, 2012 07:23 PM|LINK
Did you host your application in iis?
If you dont then host it and then try to add the reference from the url you have hosted.
My Blog
LinkedIn Profile
nil68
Member
20 Points
12 Posts
Re: 'Consuming' a Web Service from a 'Windows Forms Application' fails..!
Feb 09, 2012 07:30 PM|LINK
I am new to .net, please explain me in detail what exactly I need to do ?
Say My URL: http://localhost:1451/Service1.asmx
From my 'Windows Forms Application' , I am referencing this (as per the Book !!) now I can open my IIS (Start --> Run --> inetmgr). Now pl. explain how to host this URL?
kushalrdalal
Contributor
7130 Points
1273 Posts
Re: 'Consuming' a Web Service from a 'Windows Forms Application' fails..!
Feb 09, 2012 07:37 PM|LINK
Go to your iis
There are lots of articles available.
http://krismanohar.com/blog/?p=34
http://forums.asp.net/t/1494735.aspx/1
http://forums.iis.net/t/1159308.aspx
Basically you go to iis and then add your web service as an application.
so it will give you url like this
http://localhost/Service1.asmx
My Blog
LinkedIn Profile
nil68
Member
20 Points
12 Posts
Re: 'Consuming' a Web Service from a 'Windows Forms Application' fails..!
Feb 09, 2012 08:43 PM|LINK
I installed VS 2010 Ultimate and SQL Server 2008 R in this same XP Professional Machine. I have IIS 5.1 running. So the above link for adding Web Site does not work or may be has to be done in different way.
So, advise me on IIS 5.1 bases.
kushalrdalal
Contributor
7130 Points
1273 Posts
Re: 'Consuming' a Web Service from a 'Windows Forms Application' fails..!
Feb 09, 2012 08:57 PM|LINK
Go to your iis.
Try to find Sites under Start Page and your computer name on left side.
Then click on Sites and then click on Default Web Site.
Right cilck on Default Site and Add Application.
In Add Application pop up put the information and under physical path where is your web service is located.
Give the name whatever you want to give in alias.
Thats it.
Then click on that newly created site and browse from the right side.
The url you get try to use that url in your visual studio when you try to add reference.
My Blog
LinkedIn Profile
nil68
Member
20 Points
12 Posts
Re: 'Consuming' a Web Service from a 'Windows Forms Application' fails..!
Feb 09, 2012 10:03 PM|LINK
in IIS 5.1, thesr is no 'Add Web Site' by right clicl on 'Default Web Site'. In the Property Tab pages, I don't see any.
Internet research on IIS 5.1 http://forums.iis.net/t/1138192.aspx says can't add more than one 'default' web site
kushalrdalal
Contributor
7130 Points
1273 Posts
Re: 'Consuming' a Web Service from a 'Windows Forms Application' fails..!
Feb 09, 2012 11:16 PM|LINK
Check for Add Application or Add Virtual Directory.
My Blog
LinkedIn Profile
nil68
Member
20 Points
12 Posts
Re: 'Consuming' a Web Service from a 'Windows Forms Application' fails..!
Feb 10, 2012 06:57 PM|LINK
I have added the following link to the IIS 5.1 --> "Home Directory" Tab --> Application Name
C:\Project Workplace\ASP.NET Web Services\AddNumbers\AddNumbers\Service1.asmx
Restarted the IIS and Ran the application .. did not work,
Then I put C:\Project Workplace\ASP.NET Web Services\AddNumbers\WebClient\Form1.cs
in the IIS 5.1 --> "Home Directory" Tab --> Application Name
Restarted the IIS and Ran the application .. STILL did not work,
My Client Application in in the same Project of the the "Seb Service" it can Reference the Web Service "Discovery" button.
But While Run time it only shows the following Error:-
Directory Listing -- /
BTW: WebMethod is as follows:-
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public Decimal add(Decimal a, Decimal b)
{
Decimal dc;
dc = a + b;
return dc;
}
}
N.B. When I Run the Add() Web Service, I must have to keep the "Cursor" of the First Line i.e. front of
using System; using System.Collections.Generic;
Otherwise I get above "Directory Listing " Error.. If I put my Cursot on the Code page, the Web Service Runs alone. But Calling From Client Never Works (After Consuming From Client application)
My Client Call:-
private void button1_Click(object sender, EventArgs e)
{
Decimal a, b, result;
var client = new WebClientRef.Service1();
a = Convert.ToDecimal(textBox1.Text);
b = Convert.ToDecimal(textBox2.Text);
result = client.add(a, b);
MessageBox.Show("The Total of :" + Convert.ToString(result));
}
kushalrdalal
Contributor
7130 Points
1273 Posts
Re: 'Consuming' a Web Service from a 'Windows Forms Application' fails..!
Feb 10, 2012 07:38 PM|LINK
Now right click on serivce1.asmx and then browse.
The url you got try to add that as a reference.
My Blog
LinkedIn Profile