自托管wcf服务,wsdl引用localhost

时间:2015-05-19 11:48:49

标签: c# asp.net wcf iis

我有一个托管服务的Web应用程序。 我用以下方式启动服务:

Uri uri = new Uri(String.Format("http://localhost:{0}/", 12345));
_externalServiceHost = new ServiceHost(typeof(MyExternalService), uri);

当我运行它并想要访问wsdl时,它只包含指向localhost的链接。但是当我从我的机器上访问wsdl时,链接总是在localhost上。如何配置它始终指向正确的服务器?

Ps:我正在使用Visual Studio 2008和.Net 3.5

1 个答案:

答案 0 :(得分:1)

在你的web.config中,应该有一个看起来像这样的块。更改地址属性。

<service name="YOUR.SERVICE.TYPE"
                behaviorConfiguration="YOUR.SERVICE.BEHAVIOR">
         <endpoint name="basicHttpBinding"
                   address="http://your.domain.com/your/service/type"
                   binding="basicHttpBinding"
                   contract="YOUR.SERVICE.CONTRACT"/>
         <endpoint name="mexHttpBinding"
                   contract="IMetadataExchange"
                   binding="mexHttpBinding"
                   address="mex" />
</service>
相关问题