【发布时间】:2016-03-01 13:19:10
【问题描述】:
我正在尝试使用以下代码调用内部网络服务:
using (FastquoteWcfServiceClient fastQuoteClient = new FastquoteWcfServiceClient())
{
var request = new SearchProjectsRequest
{
GeoLocationDetails = new GeoLocationSearchRequest { Postcode = fullPostcode },
PageSize = 20,
IncludeCompletedProjects = false
};
try
{
ProjectSearchResponse response = fastQuoteClient.SearchProjects(request);
if (response != null)
{
return response.Projects;
}
}
catch
{
}
}
和配置:
<endpoint address="http://devwcfinternal/FastquoteWcfService/FastquoteWcfService.svc"
binding="basicHttpBinding"
bindingConfiguration="fastquote"
contract="FastQuoteService.IFastquoteWcfService"
name="fastquoteService" />
<binding name="fastquote"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true" />
我可以浏览到 url:http://devwcfinternal/FastquoteWcfService/FastquoteWcfService.svc 并运行它并调用 wcf 测试客户端中的方法,但是当我执行代码时,我收到以下错误消息:
<h3>Oops! We couldn't find <strong>devwcfinternal</strong></h3>
有谁知道什么会导致只有代码无法解析主机名?
我们的系统人员认为这可能与 IIS 有关
【问题讨论】:
-
为了测试是否是 DNS 问题,我会在本地 lmhost 文件中设置目标主机 - 或在 wcf 配置中使用 IP(以防 IIS 响应 ip)