从控制台应用程序客户端调用时,我的 WCF 服务返回结果。但是,它正在显示
Exception: Unable to connect to remote server
实际错误:
Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.
错误详情:
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at IJiraService.GetProjects() at JiraServiceClient.GetProjects()
请注意,当 Fiddler 运行时,该服务工作正常。但是,如果我关闭 Fiddler,它会显示异常:
这是 Fiddler 日志(我正在获取数据):
TTP/1.1 200 连接建立 日期:2015 年 8 月 6 日星期四 14:39:22 GMT 代理连接:保持事件 通过:1.1 localhost.localdomain
加密的 HTTPS 流量流经此 CONNECT 隧道。 Fiddler 中启用了 HTTPS 解密,因此在此隧道中运行的解密 session 将显示在 Web session 列表中。
安全协议(protocol):Tls 密码:Aes128 128bits 哈希算法:Sha1 160bits key 交换:ECDHE_RSA (0xae06) 256bits
== 服务器证书 ========== [学科] CN=*.atlassian.net, O="Atlassian Network Services, Inc.", L=San Francisco, S=California, C=US
[发行人] 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
[指纹] EA57BE3C6CDA33E6D875889944EE61284E39D91D
HTTP/1.1 200 正常 服务器:nginx 日期:2015 年 8 月 6 日星期四 14:39:26 GMT 内容类型:application/json;charset=UTF-8 传输编码:分块 连接:保持事件状态 变化:接受编码 X-AREQUESTID:39x4118x1 X-ASEN:SEN-2425233 设置cookie:JSESSIONID=8B68E46928883CA9F99382A67C228541;路径=/;安全的;仅限HTTP 设置 Cookie:studio.crowd.tokenkey="";域名=.clientname.atlassian.net;过期=星期四,1970 年 1 月 1 日 00:00:10 GMT;路径=/;安全的;仅限HTTP X-Seraph-LoginReason:OUT 设置 Cookie:studio.crowd.tokenkey=YcO0N1IItmmGYah6bzgN0w00;域名=.clientname.atlassian.net;路径=/;安全的;仅限HTTP X-Seraph-LoginReason:OK 设置 Cookie:atlassian.xsrf.token=ALMX-0SVV-VVCK-3Y73|c420e5bfab5c997ccdfa21ffa129d60a69af0013|lin;路径=/;安全的 X-ASESSIONID:b2v6it X-用户名:admin X-ATENANT-ID:clientname.atlassian.net 缓存控制:无缓存、无存储、无转换 X 内容类型选项:nosniff 严格传输安全:max-age=315360000;includeSubDomains
根据上面的 Fiddler 日志,我必须在 web.config 文件中更改才能使其正常工作吗?
从 WCF 测试客户端调用时。这是我尝试过的:
网络配置:
<?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>
这是我在代码中请求的方式:
public class Service : IService
{
private string GetRestURL()
{
return System.Configuration.ConfigurationManager.AppSettings["resturl"];
}
private string GetUserName()
{
return System.Configuration.ConfigurationManager.AppSettings["MyUserName"];
}
private string GetPassword()
{
return System.Configuration.ConfigurationManager.AppSettings["MyPassword"];
}
public string method()
{
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
// HttpClient
request.ContentType = "application/json; charset=UTF-8";
//request.ContentType = "text/xml; charset=UTF-8";
/*request.Headers.Add("X-Atlassian-Token", "nocheck");
request.UseDefaultCredentials = true;
request.KeepAlive = true;*/
request.Method = method;
/*if (data != null)
{
using (StreamWriter writer = new StreamWriter(request.GetRequestStream(),Encoding.ASCII))
{
writer.Write(data);
}
}*/
string base64Credentials = GetEncodedCredentials();
request.Headers.Add("Authorization", "Basic " + base64Credentials);
try
{
request.Headers.Add("Authorization", "Basic " + base64Credentials);
response = request.GetResponse() as HttpWebResponse; //here its NULL
if (response.StatusCode != HttpStatusCode.OK)
{
throw new Exception(String.Format("Server error (HTTP {0}:{1}).",response.StatusCode,response.StatusDescription));
}
}
catch (Exception ex) //Here I'm getting exception
{
throw new Exception(ex.Message);
}
}
这是我的方法签名:
[ServiceContract]
public interface IService
{
[OperationContract]
List<ProjectDescription> GetProjects();
}
注意:“方法”是从“GetProjects”调用的
这是我在通过调用 WCF 测试客户端进行调试时遇到的内部异常:
这是我的内心异常
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 165.254.xxx.xxx:443
注意:当我从控制台应用程序调试时没有调试异常。正如我所说,控制台应用程序运行良好,我能够从服务返回结果。
更新:当我在控制台应用程序中将此服务添加为“添加引用”时,它工作正常。但是,当我在同一个控制台应用程序中添加为“添加服务引用”时,它显示了同样的错误。是我的网络阻止了什么吗?请帮忙。
如何纠正这个问题?我还需要在 web.config 中添加其他内容吗?或者我是否需要在某处允许该 URL 作为受信任的 URL?
最佳答案
通过在 IIS 中添加代理解决了问题。 :)
关于c# - 添加服务引用给出异常 : Unable to connect to remote server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31579822/
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
当我使用Bundler时,是否需要在我的Gemfile中将其列为依赖项?毕竟,我的代码中有些地方需要它。例如,当我进行Bundler设置时:require"bundler/setup" 最佳答案 没有。您可以尝试,但首先您必须用鞋带将自己抬离地面。 关于ruby-我需要将Bundler本身添加到Gemfile中吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/4758609/
我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..
我有一个ModularSinatra应用程序,我正在尝试将Bootstrap添加到应用程序中。get'/bootstrap/application.css'doless:"bootstrap/bootstrap"end我在views/bootstrap中有所有less文件,包括bootstrap.less。我收到这个错误:Less::ParseErrorat/bootstrap/application.css'reset.less'wasn'tfound.Bootstrap.less的第一行是://CSSReset@import"reset.less";我尝试了所有不同的路径格式,但它
我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以
最近,当我启动我的Rails服务器时,我收到了一长串警告。虽然它不影响我的应用程序,但我想知道如何解决这些警告。我的估计是imagemagick以某种方式被调用了两次?当我在警告前后检查我的git日志时。我想知道如何解决这个问题。-bcrypt-ruby(3.1.2)-better_errors(1.0.1)+bcrypt(3.1.7)+bcrypt-ruby(3.1.5)-bcrypt(>=3.1.3)+better_errors(1.1.0)bcrypt和imagemagick有关系吗?/Users/rbchris/.rbenv/versions/2.0.0-p247/lib/ru
在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo
我正在学习Rails,并阅读了关于乐观锁的内容。我已将类型为integer的lock_version列添加到我的articles表中。但现在每当我第一次尝试更新记录时,我都会收到StaleObjectError异常。这是我的迁移:classAddLockVersionToArticle当我尝试通过Rails控制台更新文章时:article=Article.first=>#我这样做:article.title="newtitle"article.save我明白了:(0.3ms)begintransaction(0.3ms)UPDATE"articles"SET"title"='dwdwd
在Cooper的书BeginningRuby中,第166页有一个我无法重现的示例。classSongincludeComparableattr_accessor:lengthdef(other)@lengthother.lengthenddefinitialize(song_name,length)@song_name=song_name@length=lengthendenda=Song.new('Rockaroundtheclock',143)b=Song.new('BohemianRhapsody',544)c=Song.new('MinuteWaltz',60)a.betwee
如何在ruby中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL