0

我正在执行以下步骤。

  1. 使用 WCF 服务库创建 WCF 服务

  2. 通过在项目中按 F5 运行和测试 WCF 服务(它运行良好)

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

  4. 将服务引用添加到我之前在步骤 1 中创建的 WCF 服务

但是,新项目无法识别我在步骤 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);


    }
}

}

4

2 回答 2

0

是否从同一个项目调用服务并不重要。

您能否检查 Fiddler 并查看正在发送的 HTTP 流量?

于 2012-09-28T15:19:39.690 回答
0

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

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

于 2012-10-01T14:46:08.493 回答