简体   繁体   English

将WCF服务从开发机移动到服务器时出错

[英]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.

相关问题 编码到WCF服务而无需从开发人员机器访问端点 - Coding to a WCF service without having access to the endpoint from dev machine WCF服务未在非开发机器上运行 - WCF service not running on non-dev machine 从Localhost开发人员到产品服务器使用WCF服务的WPF客户端? - WPF Client with WCF Service from Localhost dev to prod server? WCF服务正在开发服务器上运行,但在生产环境中无法正常运行 - WCF service is working on dev server but on production it is not woking 从另一台计算机访问WCF服务时如何解决wcf endpint错误 - How to resolve the wcf endpint error while accessing WCF service from another machine WCF服务导致错误“ ...”在服务器计算机中,对象图中可以序列化或反序列化的最大项目数为“ 65536…” - WCF service causes error '…'Maximum number of items that can be serialized or deserialized in an object graph is '65536 …' in server machine 从其托管服务器连接到WCF服务时出错 - Error connecting to WCF service from its hosting server WCF服务未托管在计算机上 - WCF Service is not hosted on the machine WCF服务的配置以及从一台计算机到另一台计算机的访问服务 - Configuration of WCF service and accessing that service from one machine to another 具有模拟功能的WCF服务无法连接到SQL Server,但是同一台计算机上的SSMS将 - WCF service with impersonate cannot connect to SQL Server, but SSMS on the same machine will
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM