从另一个项目中使用WCF服务

时间:2012-09-28 15:09:20

标签: asp.net wcf

我正在执行以下步骤。

  1. 使用WCF服务库

  2. 创建了WCF服务
  3. 按项目中的F5运行并测试WCF服务(运行正常)

  4. 在Visual Studio中的同一解决方案中创建另一个项目

  5. 将服务引用添加到我之前在步骤1中创建的WCF服务
  6. 但是,新项目无法识别我在步骤1中创建的WCF服务。如何使用在其他项目中创建的WCF服务? 从同一个项目调用时,相同的服务调用可以正常工作。我在使用HelloWorld2时遇到了红线;

      using HelloWorld2; 
    
    namespace WebApplication1
    {
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           // Helloworld2 client = new Helloworld2();
    
            // Use the 'client' variable to call operations on the service.
           // Name person = new Name();
           // person.First = "Adam";
           // person.Last = "Smith";
    
           // Response.Write(person.First);
    
    
        }
    }
    

    }

2 个答案:

答案 0 :(得分:0)

从同一个项目调用服务无关紧要。

您可以查看Fiddler并查看正在发送的HTTP流量吗?

答案 1 :(得分:0)

这是因为我错过了添加引用的代码

ServiceReference2.Helloworld2Client cc = new ServiceReference2.Helloworld2Client();             ServiceReference2.Name person = new ServiceReference2.Name();

相关问题