Error in running the WCF service

Posted by Laghaterohan under Regular Expressions on 4/4/2011 | Points: 10 | Views : 4639 | Status : [Member] | Replies : 5
Hello,

I am getting following error when i write a question What is your profession in the console...(as per article by one of our member)

Could not connect to http://localhost:8080/SampleService. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8080.


how to ovecome this?

Best Regards,
Rohan Laghate



Responses

Posted by: SheoNarayan on: 4/4/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Hi Rohan,

Try to run your visual studio as an Administrator on that machine (right click the Visual Studio icon and click Run As Administrator) and run your program, it should work.

If not, try below thread example

http://stackoverflow.com/questions/5065552/wcf-unable-to-access-over-a-network

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Laghaterohan on: 4/4/2011 [Member] Starter | Points: 25

Up
0
Down
Thanks Sheo,

but i am unable to fix the problem please help....

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Laghaterohan on: 4/4/2011 [Member] Starter | Points: 25

Up
0
Down
What changes i need to do in my app config file?

In my sample Client code i have included following lines...

static void Main(string[] args)
{
Console.WriteLine("Ask question");
//the name AnswerClient is generated autometically by svcutil.exe tool which creates
//chat proxy and app.cofig //by browsing the service url after reference.
using (AnswerClient client = new AnswerClient())
{
string hostName = System.Net.Dns.GetHostName();
int port = 8080;
Uri serviceUri = new Uri(string.Format("http://{0}:{1}", hostName, port.ToString()));
EndpointAddress endpoint = new EndpointAddress(serviceUri);


Console.WriteLine("Your Question: ");
string question = Console.ReadLine();
string answer = client.ObtainAnswer(question);
Console.WriteLine(answer); Console.ReadLine();
}

}


What Changes i need to do here??
<client>
<endpoint binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IAnswer"
contract="IAnswer" name="DefaultBinding_IAnswer_IAnswer" address="http://localhost:8080/SampleService" />

i am stuck up....
</client>

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Laghaterohan on: 4/4/2011 [Member] Starter | Points: 25

Up
0
Down
What changes i need to do in my app config file?

In my sample Client code i have included following lines...

static void Main(string[] args)
{
Console.WriteLine("Ask question");
//the name AnswerClient is generated autometically by svcutil.exe tool which creates
//chat proxy and app.cofig //by browsing the service url after reference.
using (AnswerClient client = new AnswerClient())
{
string hostName = System.Net.Dns.GetHostName();
int port = 8080;
Uri serviceUri = new Uri(string.Format("http://{0}:{1}", hostName, port.ToString()));
EndpointAddress endpoint = new EndpointAddress(serviceUri);


Console.WriteLine("Your Question: ");
string question = Console.ReadLine();
string answer = client.ObtainAnswer(question);
Console.WriteLine(answer); Console.ReadLine();
}

}


What Changes i need to do here??
<client>
<endpoint binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IAnswer"
contract="IAnswer" name="DefaultBinding_IAnswer_IAnswer" address="http://localhost:8080/SampleService" />

i am stuck up....
</client>

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nageshc on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
I Did Some Modification in App.config File Of SampleClient Application.
Those Changes are:
<client>
<!--<endpoint address="http://localhost:8080/SampleService" binding="basicHttpBinding" contract="SampleServiceLiberary.IAnswer"></endpoint>-->
<endpoint address="http://localhost:8080/SampleService" binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IAnswer"
contract="IAnswer" name="DefaultBinding_IAnswer_IAnswer" />
</client>


Just i Copied and Pasted address Property from App.config File Of Sample Host Application.
<endpoint address="http://localhost:8080/SampleService" binding="basicHttpBinding" contract="SampleServiceLiberary.IAnswer"></endpoint>

What i Come to know is: The End Points in Sample Host Application, should be same in SampleClient Application.

First we have to run Sample Host Application, then we can see this message in Command Prompt:
Sample Host of Sample Service is Running...
Again we have to Click Enter then we will see this Message: The Sample Service is Ready Now...

So Now Our Host is Ready, then i ran SampleClient Application.
Here also I done some Changes those are:
In SampleClient Application , In Program.cs file:
After string question = Console.ReadLine();
I added these Lines:
string hostName = System.Net.Dns.GetHostName();
int port = 8080;
Uri serviceUri = new Uri(string.Format("http://{0}:{1}", hostName, port.ToString()));
EndpointAddress endpoint = new EndpointAddress(serviceUri);


Then i Run the this SampleClient Application.
I got the Response.

Hi Guys i'm also new to WCF...
Just i Followed the Author Steps and i created the Service.
If any thing i went wrong Excuse me frinds!!!!

Regards
Nagesh



Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response