Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

query regarding wcf

Posted on 2011-09-25
10
Medium Priority
?
371 Views
Last Modified: 2012-05-12
Hi

I have created one wcf service. Then I added the wcf  project as reference in a web based application. Even I can use the functions defined in the service. But If I check the configuration file of the service I can see that there is no address defined.

How I can use the service if there is no address defined in the endpoint in the configuration file.

Regards
Karan Gupta
0
Comment
Question by:KaranGupta
  • 6
  • 4
10 Comments
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36597276
If you are using WCF 4, then defualt End Point is associated with the service, if we don’t configure any WCF endpoint.

Look at this detail article http://beyondrelational.com/blogs/dhananjaykumar/archive/2011/01/28/default-endpointsin-wcf-4-0.aspx
0
 

Author Comment

by:KaranGupta
ID: 36597608
But I am using WCF with visual studio 2005 express version
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36597645
Then you may be set your endpoint programatically. Like

        string baseAddress = "http://localhost:8080/wcfselfhost/";
        ServiceHost host = new ServiceHost(typeof(MyService), new Uri(baseAddress));

        // Create a BasicHttpBinding instance
        BasicHttpBinding binding = new BasicHttpBinding();

        // Add a service endpoint using the created binding
        host.AddServiceEndpoint(typeof(IEcho), binding, "echo1");

        host.Open();
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:KaranGupta
ID: 36598265
Hi

That is what I am saying. I have not set it but still I can use the function
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36598282
Please show your code. zip file
0
 

Author Comment

by:KaranGupta
ID: 36598366
Hi

Please rename the file to .rar then unrar it. sample-app.txt
0
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 2000 total points
ID: 36598396
Go to TestService >> web.config file and there you constructed the end point (address,binding,contract) under <system.serviceModel> tag

<endpoint address="http://localhost/TestService" binding="wsHttpBinding" contract="TestService.IService1">
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36598399
And I guess,  you are adding the reference using http://localhost/TestService in your TestWCFApp
0
 

Author Comment

by:KaranGupta
ID: 36599706
Hi sonawanekiran

I am adding as a reference in TestWcfApp in the same manner we normally add dll.
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36704139
Correct. The URL you are using to add service reference in your TestWCFAPP is defined in web.config of you WCF  service project (which is TestService)
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Loops Section Overview
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question