开发者

Deploying a simple WCF Service to web server

开发者 https://www.devze.com 2023-01-29 16:39 出处:网络
Created a new Directory XYZ in IIS 7.0. Copied the web.config, Service.cs and Service.svc to the directory. Now on browsing http://www.mydomain.com/XYZ/Service.svc I am getting a \'500 internal server

Created a new Directory XYZ in IIS 7.0. Copied the web.config, Service.cs and Service.svc to the directory. Now on browsing http://www.mydomain.com/XYZ/Service.svc I am getting a '500 internal server error'.

Here is the web.cofig file.

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </开发者_StackOverflowsystem.web>
  <system.serviceModel>
    <behaviors>
      <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>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

I am thinking there might be some problem with the config file, but the service runs pretty ok on local machine.


At first, you must use dll-file instead of code file. Compile code and put dll into the "bin" folder.

At second, you didn't add endpoints into web.cofnig:

<system.serviceModel>
<!-- ... -->
     <services>
        <service name="SiteService">
            <endpoint address="" binding="basicHttpBinding" 
                 contract="Name of the service interface with namespace, for exanple WebApplication1.IService1" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>      
</system.serviceModel>

And check svc file, a service name inside it should correspond to a service name inside a config file. If a service has a line <service name="SiteService">, svc file should be

<%@ ServiceHost Language="C#" Debug="true" Service="SiteService" CodeBehind="Service.cs" %>
0

精彩评论

暂无评论...
验证码 换一张
取 消