[英]Error moving WCF service from dev machine to server
This is a WCF REST service. 这是WCF REST服务。 The service works perfectly fine on my dev machine.
该服务在我的开发机上运行良好。
I have the service files in a subfolder of wwwroot called Services\\ 我将服务文件放在wwwroot的子文件夹中,称为Services \\
Admittedly I'm well versed at writing code, but no so well versed at using IIS to host/publish we services. 诚然,我对编写代码非常精通,但是对于使用IIS托管/发布我们的服务却不那么精通。
What I attempted to do was just copy the Services folder from my dev laptop to the server's wwwroot folder. 我试图做的只是将Services文件夹从我的开发笔记本电脑复制到服务器的wwwroot文件夹。
When this happens and I try to access the service on the server I get some strange error that I don't understand (well I sort of understand it just don't know why it's happening) 发生这种情况时,当我尝试访问服务器上的服务时,会收到一些我不理解的奇怪错误(嗯,我有点理解,只是不知道为什么会发生)
"The type 'BooksService.Service1', provided as the Service attribute value in the ServiceHost directive, or profided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found." “找不到类型'BooksService.Service1',在ServiceHost指令中作为服务属性值提供,或在配置元素system.serviceModel / serviceHostingEnvironment / serviceActivations中提供。”
Service1.cs looks like so in my project: Service1.cs在我的项目中看起来像这样:
namespace BooksService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
public class Service1 : IDataService
A decent portion of my web.config is based on google recommendations so it's probable I may not understand something or just have it plain wrong. 我的web.config相当不错的一部分是基于Google的建议,因此可能我可能听不懂某些内容,或者只是说错了。
Web.Config looks like: Web.Config看起来像:
***<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="BooksService.Service1">
<endpoint address="" binding="webHttpBinding" contract="BooksService.IDataService" behaviorConfiguration="restfulBehavior"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost/bookservice" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="restfulBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>***
My service file looks like this: 我的服务文件如下所示:
<% @ServiceHost Service="BooksService.Service1" %> <%@ServiceHost Service =“ BooksService.Service1”%>
Then there is a bin folder which contains my .dll 然后是一个包含我的.dll的bin文件夹
So the folder layout is as follows: 因此,文件夹布局如下:
c:\\inetpub\\wwwroot\\SERVICES\\BookService\\bin c:\\ inetpub \\ wwwroot \\ SERVICES \\ BookService \\ bin
Where service.svc is in the BookService folder and the assembly is in the bin folder. 其中service.svc在BookService文件夹中,而程序集在bin文件夹中。
What step(s) might I be missing? 我可能缺少什么步骤?
First, you need to create an application in IIS and point the virtual directory to your application folder: c:\\inetpub\\wwwroot\\SERVICES\\BookService. 首先,您需要在IIS中创建一个应用程序,并将虚拟目录指向您的应用程序文件夹:c:\\ inetpub \\ wwwroot \\ SERVICES \\ BookService。
Then you need to update your service base address accordingly: 然后,您需要相应地更新服务基本地址:
<baseAddresses>
<add baseAddress="http://localhost/services/bookservice" />
</baseAddresses>
You can test the url by typing it in your browser and browsing to the service location. 您可以通过在浏览器中键入URL并浏览到服务位置来测试URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.