0

I have created a WCF webservice using WCF Service Application template in VS 2008. In the same solution i have created a web application project and added the web reference to the service where i gave the service url.

Now when i call the service method from my web application project, i get a timeout, i cannot get the O/P from calling service method. Here's my code i am using to call method from service:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebApplicationClient.WCFService;

namespace WebApplicationClient
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Service1 svc1 = new Service1();
            String ex = svc1.GetData(1,true);


        }
    }
}

EDIT: I have figured out the problem. I added a Web Reference to the service rather than the Service reference and it worked.Can anyone tell me the difference b/w the two?

Also when i run the WCF service , i get this message: Run this command from Command window:

 svcutil.exe http://localhost:1787/Service1.svc?wsdl

But svcutil.exe is not recognised by the OS. I guess it is placed somehwere and i have to give the path also, is this the problem?Where can i find this?

7
  • Are your WCF services started up?
    – RQDQ
    Jun 11, 2012 at 7:03
  • @RQDQ Yes, i have figured out the problem. I added a Web Reference to the service rather than the Service reference and it worked.Can you tell me the difference b/w the two?
    – Charu
    Jun 11, 2012 at 7:06
  • 1
    Web reference is the older web service stack (SOAP only I believe). Service reference is the newer WCF stack. However, if you were able to set a web reference, it should have worked fine...
    – RQDQ
    Jun 11, 2012 at 7:11
  • 1
    Look here for some explanation.
    – CodeCaster
    Jun 11, 2012 at 7:12
  • @RQDQ No it is not working with WEb Reference.Also i have edited the questions with a few more doubts.
    – Charu
    Jun 11, 2012 at 7:12

1 Answer 1

1

But svcutil.exe is not recognised by the OS. I guess it is placed somehwere and i have to give the path also, is this the problem?Where can i find this?

SvcUtil.exe is the utility that helps to create proxy for a wcf service. You can easily access the utility by opening the Visual Studio command prompt not the windows command prompt.

If you have installed VS in C drive it would be located here.

C:\Program Files\ Microsoft Visual Studio 10.0\VC

This thread talks about the difference between Add Web Reference and Add Service Reference. In your case I would suggest to use Service Reference not Web Reference.

3
  • I get an error when i try to run it.Error: Cannot create output file: C:\Program Files\Microsoft Visual Studio 9.0\V C\Service1.cs Access to the path 'C:\Program Files\Microsoft Visual Studio 9.0\VC\Service1 .cs' is denied. I donot have admin rights , is this the problem? Can i change the path where it generates the o/p.
    – Charu
    Jun 11, 2012 at 9:11
  • 1
    Once you opened the VS command prompt just move to some other drive say D: or E: and then invoke the svcutil.exe. Ex. D:\>svcutil.exe localhost:1787/Service1.svc?wsdl
    – VJAI
    Jun 11, 2012 at 9:25
  • I cannot do CD D:, dont know why, i will try the same at my home machine and see if it works.
    – Charu
    Jun 11, 2012 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.