C# 添加服务引用出现异常:无法连接到远程服务器
我的WCF服务在从控制台应用程序客户端调用时返回结果。然而,它正在显现 异常:无法连接到远程服务器 实际误差: 未能调用该服务。可能原因:服务离线或无法访问;客户端配置不匹配 代理人;现有代理无效。有关详细信息,请参阅堆栈跟踪 更多细节。您可以尝试通过启动一个新的代理进行恢复,恢复 默认配置,或刷新服务 错误详细信息: 由于内部错误,服务器无法处理该请求。 有关错误的详细信息,请启用 IncludeExceptionDetailInFaults(来自ServiceBehaviorAttribute 或从中的服务器上的配置行为) 命令将异常信息发送回客户端,或打开 根据Microsoft.NET Framework SDK文档和 检查服务器跟踪日志 服务器堆栈跟踪:在 System.ServiceModel.Channels.ServiceChannel.ThrowiffaultUnderstanding(消息 回复,MessageFault故障,字符串操作,MessageVersion版本, 故障转换器(故障转换器)位于 System.ServiceModel.Channel.ServiceChannel.HandlerReply(ProxyOperationRuntime 操作,ProxyRpc&rpc)在 System.ServiceModel.Channel.ServiceChannel.Call(字符串操作, 布尔单向,ProxyOperationRuntime操作,对象[]ins, 对象[]输出,TimeSpan超时)位于 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage 方法调用,ProxyOperationRuntime操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage (信息) 在[0]处重试异常:在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& 位于IJiraService.GetProjects()的 JiraServiceClient.GetProjects() 请注意,当Fiddler运行时,服务工作正常。但是,如果我关闭Fiddler,则会显示异常: 这是Fiddler日志(当我获取数据时): TTP/1.1 200已建立连接 日期:2015年8月6日星期四14:39:22 GMT 代理连接:保持活动状态 Via:1.1 localhost.localdomain 加密的HTTPS流量通过此连接隧道。在Fiddler中启用了HTTPS解密,因此在此隧道中运行的解密会话将显示在Web会话列表中 安全协议:Tls 密码:128位 哈希算法:Sha1 160位 密钥交换:ECDHE_RSA(0xae06)256位 ==服务器证书========== [主题] CN=*.atlassian.net,O=“atlassian网络服务公司”,L=旧金山,S=加利福尼亚,C=美国 [发行人] CN=DigiCert SHA2高保证服务器CA,OU=www.DigiCert.com,O=DigiCert Inc,C=US [序列号] 08E828A2F8C521A2DC7121A28E191837 [之前没有] 2014年9月9日上午5:30:00 [不在之后] 2017年11月15日下午5:30:00 [指纹] EA57BE3C6CDA33E6D875889944EE61284E39D91DC# 添加服务引用出现异常:无法连接到远程服务器,c#,asp.net,.net,wcf,web,C#,Asp.net,.net,Wcf,Web,我的WCF服务在从控制台应用程序客户端调用时返回结果。然而,它正在显现 异常:无法连接到远程服务器 实际误差: 未能调用该服务。可能原因:服务离线或无法访问;客户端配置不匹配 代理人;现有代理无效。有关详细信息,请参阅堆栈跟踪 更多细节。您可以尝试通过启动一个新的代理进行恢复,恢复 默认配置,或刷新服务 错误详细信息: 由于内部错误,服务器无法处理该请求。 有关错误的详细信息,请启用 IncludeExceptionDetailInFaults(来自ServiceBehaviorAttribut
HTTP/1.1200ok 服务器:nginx 日期:2015年8月6日星期四14:39:26 GMT 内容类型:application/json;字符集=UTF-8 传输编码:分块 连接:保持活力 改变:接受编码 X-AREQUESTID:39x4118x1 X-ASEN:SEN-2425233 设置Cookie:JSESSIONID=8B68E4692883CA9F99382A67C228541;路径=/;保护HttpOnly 设置Cookie:studio.crowd.tokenkey=“”;Domain=.clientname.atlassian.net;Expires=1970年1月1日星期四00:00:10 GMT;路径=/;保护HttpOnly X-Seraph-Login原因:出局 设置Cookie:studio.crowd.tokenkey=YcO0N1IItmmGYah6bzgN0w00;Domain=.clientname.atlassian.net;路径=/;保护HttpOnly 原因:好的 设置Cookie:atlassian.xsrf.token=ALMX-0SVV-VVCK-3Y73 | c420e5bfab5c997ccdfa21ffa129d60a69af0013 | lin;路径=/;保护 X-ASESSIONID:b2v6it X-AUSERNAME:管理员 X-ATENANT-ID:clientname.atlassian.net 缓存控制:无缓存、无存储、无转换 X-Content-Type-Options:nosniff 严格的运输安全:最大年龄=315360000;包含子域 根据上述Fiddler日志,我必须在web.config文件中更改它才能正常工作? 从WCF测试客户端调用时。以下是我尝试过的: Web.config:
<?xml version="1.0"?>
<configuration>
<!--<system.net>
<defaultProxy useDefaultCredentials="true" >
</defaultProxy>
</system.net>-->
<appSettings>
<add key="UserName" value="admin"/>
<add key="Password" value="admin"/>
<add key="resturl" value="https://Clientname.atlassian.net/rest/api/2/"/>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IJiraService"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:19065/JiraService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IJiraService" contract="ServiceReference1.IJiraService"
name="BasicHttpBinding_IJiraService" />
</client>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
这是我的方法签名:
[ServiceContract]
public interface IService
{
[OperationContract]
List<ProjectDescription> GetProjects();
}
[服务合同]
公共接口设备
{
[经营合同]
列出GetProjects();
}
注意:“方法”是从“GetProjects”调用的
这是调用WCF测试客户端进行调试时得到的内部异常:
这是我内心的异常
连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机未能响应165.254.xxx.xxx:443
注意:当我从控制台应用程序调试时,没有调试异常。正如我所说,控制台应用程序运行良好,我能够从服务返回结果
更新:当我在控制台应用程序中将此服务添加为“添加引用”时,它工作正常。然而,当我在同一个控制台应用程序中添加为“添加服务引用”时,它显示了相同的错误。是不是我的网络阻止了什么?请帮忙
如何纠正这一点?是否需要在
web.config
中添加其他内容?或者我需要允许该URL作为某个受信任的URL吗?您尝试过这个答案吗?听起来它解决了您遇到的问题:
尝试调整HTTPS的绑定,并确保同时配置http
<protocolMapping>
<!--<add binding="basicHttpBinding" scheme="http"/>-->
<add binding="basicHttpsBinding" scheme="https"/>
<add binding="webHttpBinding" scheme="https" bindingConfiguration="WebBinding"/>
</protocolMapping>
通过在IIS中添加代理解决了问题。:) 你能给我们看一下你的REST
服务方法的签名吗?用签名更新了我的问题。如果我理解正确-你设置了http连接,我没有?但从错误的混乱中
<protocolMapping>
<!--<add binding="basicHttpBinding" scheme="http"/>-->
<add binding="basicHttpsBinding" scheme="https"/>
<add binding="webHttpBinding" scheme="https" bindingConfiguration="WebBinding"/>
</protocolMapping>