简体   繁体   English

如何将WCF服务上传到网站?

[英]How do I upload a WCF service to a website?

I have a test WCF project. 我有一个测试WCF项目。 In the same solution I have a C# application that uses that WCF project by simply adding it as a resource and it works well. 在同一解决方案中,我有一个C#应用程序,只需将其添加为资源即可使用该WCF项目,并且效果很好。 But how do I upload it (-WCF) to a website? 但是,如何将其(-WCF)上传到网站?

I tried Build -> Publish. 我尝试了Build-> Publish。 But it didn't give me any dialog; 但这并没有给我任何对话。 it just said "Publish succeeded". 它只是说“发布成功”。 So I converted it to a web application (right click in solution explorer...) and then published it. 因此,我将其转换为Web应用程序(在解决方案资源管理器中右键单击...),然后将其发布。 Since I wanted to try it – I published it to the file system. 由于我想尝试–我将其发布到文件系统中。 But when I now try to add a service reference to it in a C# app – I get the error that "No services were found in the solution". 但是,当我现在尝试在C#应用程序中向其添加服务引用时,出现错误“解决方案中未找到服务”。 Why is that? 这是为什么?

But the question is mainly: when I try to publish it to a website – I don't know what to put as "Service URL" and what as "Site/application". 但是主要的问题是:当我尝试将其发布到网站上时–我不知道将其放置为“服务URL”以及将其放置为“站点/应用程序”。

Here's what I have: 这是我所拥有的:

Iservice1: 服务1:

 [ServiceContract]
public interface IService1
{
    [OperationContract]
    string DoWork();
}

Service1: 服务1:

public class Service1 : IService1
{
    public string DoWork()
    {
        return "Hello, world";
    }
}

And in the C# app: 在C#应用中:

Service1Client s = new Service1Client();
Text = s.DoWork();

I prefer to build a Deployment Package and then deploying it to IIS either from IIS itself or using MSDeploy . 我更喜欢先构建一个Deployment Package ,然后从IIS本身或使用MSDeploy将其部署到IIS。 You can use the package to deploy your services on any machine you want. 您可以使用该软件包在所需的任何计算机上部署服务。 Check this walkthrough . 检查此演练

因此,最后我只是构建了一个Web应用程序,并向其中添加了WCF服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM