【发布时间】:2012-01-14 03:08:27
【问题描述】:
我有以下 WCF 服务的配置文件。配置中定义了一个主机。尽管如此,当我从客户端打印服务地址时,它并不知道主机。打印结果是:
为什么不考虑主机名?我们需要对其进行哪些修改?
注意:我从 VS 2010 运行服务和客户端网站。
Service1Client myClientService = new Service1Client();
Response.Write(myClientService.Endpoint.Address);
客户端配置(由 Visual Studio 自动生成)
<client>
<endpoint address="http://localhost:3187/Service1.svc/MyFolder"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="MyWCFReference.IService1" name="WSHttpBinding_IService1">
<identity>
<userPrincipalName value="U16990@ustr.com" />
</identity>
</endpoint>
</client>
服务器端配置为:
<services>
<!--MyService-->
<service name="MyWCFServiceApplication.MyService"
behaviorConfiguration="WeatherServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:80/ServiceModelSamples/FreeServiceWorld"/>
</baseAddresses>
</host>
<endpoint address="MyFolder"
binding="wsHttpBinding"
contract="MyWCFServiceApplication.IService1" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WeatherServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
【问题讨论】:
标签: c# asp.net .net wcf visual-studio-2010