简体   繁体   中英

Hosting WCF Service on IIS

I am new to WCF and windows mobile development. I am trying to create an occasionally connected application that utilizes the MSFT sync framework and this requires the use of a WCF service.

I have a visual studio project containing my smart device project, a WCF Service Library project, and a WCF Service website project.

The service is hosted fine on my local machine not using IIS and I can access it at http://localhost:55149/ElectricReadingServiceSite/ElectricReading.svc

However when I add it to IIS it gives me an http 404 resource cannot be found error. I cannot figure out why it thinks the resource is not there.

Here is my web.config:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="MiddleTierServiceLibrary.ElectricReadingCacheSyncService" 
               behaviorConfiguration="MiddleTierServiceLibrary.ElectricReadingCacheSyncServiceBehavior">
        <endpoint 
            address=""  
            binding="basicHttpBinding"  
            contract="MiddleTierServiceLibrary.IElectricReadingCacheSyncContract">
          <identity>
            <dns value="10.104.238.123"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MiddleTierServiceLibrary.ElectricReadingCacheSyncServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

My ElectricReading.svc looks like this:

<%@ ServiceHost Language="C#" Debug="true" 
        Service="MiddleTierServiceLibrary.ElectricReadingCacheSyncService" %>

Any help is greatly appreciated!

EDIT: Are there any tools or steps I can take to get a better idea of what is going wrong? The 404 error does very little to help me.

There can be a number of reasons to why this could be happening.

Some of them might include:

  • Make sure you uploaded the assembly in the Bin folder
  • You have set up a website on IIS, but you are not accessing it with the correct address(make sure the port is correct)
  • Your application pool is not set up for the website(if you are using .NET 4.0 you need to set the applictation pool to version 4.0) In IIS manager go to ApplicationPools and set the pool to the version of .NET that you are using

Try using Fiddler . It should log the calls it makes and thus give you a little more detail on what it is not finding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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