在Bloomberg Web Services中使用DownloadString时,System.Net.WebClient获取ConnectionReset

时间:2019-04-26 15:38:11

标签: c# http soap wsdl webclient

我使用的C#/。NET应用程序具有与外部Web服务集成的功能。对于通信,我们利用从.NET System.Net.WebClient类继承的类构建。

在尝试从彭博网站检索WSDL进行测试时,我们似乎已断开连接,而没有其他指示。看起来好像获得了成功的HTTPS连接,但是当尝试读取响应时,远程站点只是断开连接。我们只是调用System.Net.WebClient.DownloadString()方法并传递WSDL URL:https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL

webClient = new HttpWebClient();
UriBuilder uriBuilder = new UriBuilder(this.ServiceUrl);
uriBuilder.Query = "WSDL";
webClient.Headers.Add("Content-Type", "text/xml; charset=utf-8");
this.RawWsdlData = webClient.DownloadString(uriBuilder.Uri);

通过将相同的URL放入浏览器中,我们已经能够验证URL是否正确,从而使我们获得了所请求的WSDL。

我已打开System.Net跟踪,并且能够获取内部跟踪。请注意,HttpWebClient是我们从System.Net.WebClient继承的类。

    Log started for PID = 6564, TID = 26
    Getting WSDL from service (https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL)
    System.Net Verbose: 0 : [2072] Entering HttpWebClient#21999770::DownloadString(https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL#-917497223)
    System.Net Verbose: 0 : [2072] Entering HttpWebClient#21999770::DownloadData(https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL#-917497223)
    System.Net Verbose: 0 : [2072] Entering WebRequest::Create(https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL)
    System.Net Verbose: 0 : [2072] Entering HttpWebRequest#49164730::HttpWebRequest(https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL#-917497223)
    System.Net Information: 0 : [2072] Current OS installation type is 'Client'.
    System.Net Information: 0 : [2072] RAS supported: True
    System.Net Verbose: 0 : [2072] Exiting HttpWebRequest#49164730::HttpWebRequest() 
    System.Net Verbose: 0 : [2072] Exiting WebRequest::Create()        -> HttpWebRequest#49164730
    System.Net Verbose: 0 : [2072] Entering HttpWebRequest#49164730::GetResponse()
    System.Net Error: 0 : [2072] Can't retrieve proxy settings for Uri 'https://service.bloomberg.com/assets/dl/dlws.wsdl?WSDL'. Error code: 12180.
    System.Net Verbose: 0 : [2072] Entering ServicePoint#10615457::ServicePoint(service.bloomberg.com:443)
    System.Net Information: 0 : [2072] Associating HttpWebRequest#49164730 with ServicePoint#10615457
    System.Net Information: 0 : [2072] Associating Connection#16234150 with HttpWebRequest#49164730
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#24691947::Socket(AddressFamily#2)
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#24691947::Socket() 
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#7067698::Socket(AddressFamily#23)
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#7067698::Socket() 
    System.Net.Sockets Verbose: 0 : [2072] Entering DNS::TryInternalResolve(service.bloomberg.com)
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#24691947::Connect(69.191.242.179:443#-1275937026)
    System.Net.Sockets Information: 0 : [2072] Socket#24691947 - Created connection from 10.2.7.102:52684 to 69.191.242.179:443.
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#24691947::Connect() 
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#7067698::Close()
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#7067698::Dispose()
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#7067698::Close() 
    System.Net Information: 0 : [2072] Connection#16234150 - Created connection from 10.2.7.102:52684 to 69.191.242.179:443.
    System.Net Information: 0 : [2072] TlsStream#32181663::.ctor(host=service.bloomberg.com, #certs=0, checkCertificateRevocationList=False, sslProtocols=Default)
    System.Net Information: 0 : [2072] Associating HttpWebRequest#49164730 with ConnectStream#18140357
    System.Net Information: 0 : [2072] HttpWebRequest#49164730 - Request: GET /assets/dl/dlws.wsdl?WSDL HTTP/1.1

    System.Net Information: 0 : [2072] ConnectStream#18140357 - Sending headers
    {
    Content-Type: text/xml; charset=utf-8
    Host: service.bloomberg.com
    Connection: Keep-Alive
    }.
    System.Net Information: 0 : [2072] SecureChannel#31141938::.ctor(hostname=service.bloomberg.com, #clientCertificates=0, encryptionPolicy=RequireEncryption)
    System.Net Information: 0 : [2072] Enumerating security packages:
    System.Net Information: 0 : [2072]     Negotiate
    System.Net Information: 0 : [2072]     NegoExtender
    System.Net Information: 0 : [2072]     Kerberos
    System.Net Information: 0 : [2072]     NTLM
    System.Net Information: 0 : [2072]     TSSSP
    System.Net Information: 0 : [2072]     pku2u
    System.Net Information: 0 : [2072]     WDigest
    System.Net Information: 0 : [2072]     Schannel
    System.Net Information: 0 : [2072]     Microsoft Unified Security Protocol Provider
    System.Net Information: 0 : [2072]     Default TLS SSP
    System.Net Information: 0 : [2072]     CREDSSP
    System.Net Information: 0 : [2072] SecureChannel#31141938 - Left with 0 client certificates to choose from.
    System.Net Information: 0 : [2072] SecureChannel#31141938::.AcquireClientCredentials, new SecureCredential() (flags=(ValidateManual, NoDefaultCred, SendAuxRecord), m_ProtocolFlags=(Ssl3Client, Tls10Client), m_EncryptionPolicy=RequireEncryption)
    System.Net Information: 0 : [2072] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
    System.Net Information: 0 : [2072] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = service.bloomberg.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
    System.Net Information: 0 : [2072] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=125, returned code=ContinueNeeded).
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#24691947::Send()
    System.Net.Sockets Verbose: 0 : [2072] Data from Socket#24691947::Send
    System.Net.Sockets Verbose: 0 : [2072] 00000000 : 16 03 01 00 78 01 00 00-74 03 01 5C C2 03 9A 43 : ....x...t..\...C
    System.Net.Sockets Verbose: 0 : [2072] 00000010 : 54 67 9D 98 2C 4E 6B B9-A4 4C D5 8D 08 BC 03 36 : Tg..,Nk..L.....6
    System.Net.Sockets Verbose: 0 : [2072] 00000020 : 03 5F E6 D2 DA 82 2E AC-C4 C8 15 00 00 0E C0 0A : ._..............
    System.Net.Sockets Verbose: 0 : [2072] 00000030 : C0 09 C0 14 C0 13 00 35-00 2F 00 0A 01 00 00 3D : .......5./.....=
    System.Net.Sockets Verbose: 0 : [2072] 00000040 : 00 00 00 1A 00 18 00 00-15 73 65 72 76 69 63 65 : .........service
    System.Net.Sockets Verbose: 0 : [2072] 00000050 : 2E 62 6C 6F 6F 6D 62 65-72 67 2E 63 6F 6D 00 0A : .bloomberg.com..
    System.Net.Sockets Verbose: 0 : [2072] 00000060 : 00 08 00 06 00 1D 00 17-00 18 00 0B 00 02 01 00 : ................
    System.Net.Sockets Verbose: 0 : [2072] 00000070 : 00 23 00 00 00 17 00 00-FF 01 00 01 00          : .#...........
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#24691947::Send()   -> Int32#125
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#24691947::Receive()
    System.Net.Sockets Error: 0 : [2072] Socket#24691947::UpdateStatusAfterSocketError() - ConnectionReset
    System.Net.Sockets Error: 0 : [2072] Exception in Socket#24691947::Receive - An existing connection was forcibly closed by the remote host.
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#24691947::Receive()       -> Int32#0
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#24691947::Dispose()
    System.Net Error: 0 : [2072] Exception in HttpWebRequest#49164730:: - The underlying connection was closed: An unexpected error occurred on a send..
    System.Net Information: 0 : [2072] Associating HttpWebRequest#49164730 with ServicePoint#10615457
    System.Net Information: 0 : [2072] Associating Connection#39028125 with HttpWebRequest#49164730
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#26207244::Socket(AddressFamily#2)
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#26207244::Socket() 
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#38017319::Socket(AddressFamily#23)
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#38017319::Socket() 
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#26207244::Connect(69.191.242.179:443#-1275937026)
    System.Net.Sockets Information: 0 : [2072] Socket#26207244 - Created connection from 10.2.7.102:52685 to 69.191.242.179:443.
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#26207244::Connect() 
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#38017319::Close()
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#38017319::Dispose()
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#38017319::Close() 
    System.Net Information: 0 : [2072] Connection#39028125 - Created connection from 10.2.7.102:52685 to 69.191.242.179:443.
    System.Net Information: 0 : [2072] TlsStream#50247169::.ctor(host=service.bloomberg.com, #certs=0, checkCertificateRevocationList=False, sslProtocols=Default)
    System.Net Information: 0 : [2072] Associating HttpWebRequest#49164730 with ConnectStream#41123459
    System.Net Information: 0 : [2072] HttpWebRequest#49164730 - Request: GET /assets/dl/dlws.wsdl?WSDL HTTP/1.1

    System.Net Information: 0 : [2072] ConnectStream#41123459 - Sending headers
    {
    Content-Type: text/xml; charset=utf-8
    Host: service.bloomberg.com
    Connection: Keep-Alive
    }.
    System.Net Information: 0 : [2072] SecureChannel#53272024::.ctor(hostname=service.bloomberg.com, #clientCertificates=0, encryptionPolicy=RequireEncryption)
    System.Net Information: 0 : [2072] SecureChannel#53272024 - Left with 0 client certificates to choose from.
    System.Net Information: 0 : [2072] Using the cached credential handle.
    System.Net Information: 0 : [2072] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = service.bloomberg.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
    System.Net Information: 0 : [2072] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=125, returned code=ContinueNeeded).
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#26207244::Send()
    System.Net.Sockets Verbose: 0 : [2072] Data from Socket#26207244::Send
    System.Net.Sockets Verbose: 0 : [2072] 00000000 : 16 03 01 00 78 01 00 00-74 03 01 5C C2 03 9A D8 : ....x...t..\....
    System.Net.Sockets Verbose: 0 : [2072] 00000010 : 38 E3 3A 39 65 29 89 69-19 11 28 40 22 A3 87 9F : 8.:9e).i..(@"...
    System.Net.Sockets Verbose: 0 : [2072] 00000020 : 0C 7A 2D C6 9F 0A 67 D9-F1 78 CA 00 00 0E C0 0A : .z-...g..x......
    System.Net.Sockets Verbose: 0 : [2072] 00000030 : C0 09 C0 14 C0 13 00 35-00 2F 00 0A 01 00 00 3D : .......5./.....=
    System.Net.Sockets Verbose: 0 : [2072] 00000040 : 00 00 00 1A 00 18 00 00-15 73 65 72 76 69 63 65 : .........service
    System.Net.Sockets Verbose: 0 : [2072] 00000050 : 2E 62 6C 6F 6F 6D 62 65-72 67 2E 63 6F 6D 00 0A : .bloomberg.com..
    System.Net.Sockets Verbose: 0 : [2072] 00000060 : 00 08 00 06 00 1D 00 17-00 18 00 0B 00 02 01 00 : ................
    System.Net.Sockets Verbose: 0 : [2072] 00000070 : 00 23 00 00 00 17 00 00-FF 01 00 01 00          : .#...........
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#26207244::Send()   -> Int32#125
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#26207244::Receive()
    System.Net.Sockets Error: 0 : [2072] Socket#26207244::UpdateStatusAfterSocketError() - ConnectionReset
    System.Net.Sockets Error: 0 : [2072] Exception in Socket#26207244::Receive - An existing connection was forcibly closed by the remote host.
    System.Net.Sockets Verbose: 0 : [2072] Exiting Socket#26207244::Receive()       -> Int32#0
    System.Net.Sockets Verbose: 0 : [2072] Entering Socket#26207244::Dispose()
    System.Net Error: 0 : [2072] Exception in HttpWebRequest#49164730:: - The underlying connection was closed: An unexpected error occurred on a send..
    System.Net Error: 0 : [2072] Exception in HttpWebRequest#49164730::GetResponse - The underlying connection was closed: An unexpected error occurred on a send..
    System.Net Verbose: 0 : [2072] Entering HttpWebRequest#49164730::Abort()
    System.Net Error: 0 : [2072] Exception in HttpWebRequest#49164730:: - The request was aborted: The request was canceled..
    System.Net Verbose: 0 : [2072] Exiting HttpWebRequest#49164730::Abort()

作为HTTPS连接,我本来希望看到SSL / TLS类型错误,但这仅显示了远程断开连接,没有其他内容。

任何人对于可能的原因或进一步的调试方法都有任何想法吗?我可以随意复制它,所以这不是一个随机的问题。

0 个答案:

没有答案