wcf host iis

Person.svc

 

<%@ ServiceHost Language="C#" Debug="true" Service="PersonService.PersonS"  %>

注意这里的Service直接应用dll文件中的名称空间+类名就可以了,不用置顶dll文件所在的位置了,系统会自动根据名称去所有的dll文件中按照名称来查找。

PersonService.DLL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PersonService
{
    public class PersonS:IPerson
    {
        public string GetName()
        {
            return "abcd"; ;
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace PersonService
{
    [ServiceContract]
    public interface IPerson
    {
        [OperationContract]
        string GetName();
    }
}

web.config

<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
    </system.web>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior>
                    <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
                    <serviceMetadata httpGetEnabled="true"/>
                    <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>
</configuration>

 

 

posted @ 2013-11-21 21:38  feidaochuanqing  阅读(170)  评论(0编辑  收藏  举报