日期:2014-05-18 浏览次数:21610 次
namespace WCFServiceServer
{
class Program
{
static void Main(string[] args)
{
string url = "http://localhost:8000/ToolServices";
ServiceHost host = new ServiceHost(typeof(ToolServiceProvider),
new Uri(url));
host.AddServiceEndpoint(typeof(IToolService), new BasicHttpBinding(), "");
host.Open();
Console.WriteLine(string.Format("服务已启动,监控的服务为{0}",url));
Console.ReadLine();
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<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="WCFService.ToolServiceProvider" behaviorConfiguration="">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8000/ToolServices" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address ="" binding="wsHttpBinding" contract="WCFService.IToolService">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<!--<identity>
<dns value="localhost"/>
</identity>-->
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->