简体   繁体   English

连接到安全 Web 服务时出错!

[英]Error connecting to secure web service!

I am consistently receiving the following error when trying to create a Web Reference in Visual Studio 2008 to a 3rd party web service.尝试在 Visual Studio 2008 中创建对 3rd 方 Web 服务的 Web 引用时,我始终收到以下错误。

'Received an unexpected EOF or 0 bytes from the transport stream' '从传输流中收到意外的 EOF 或 0 字节'

I get the same error too if I try to generate a proxy class vith the wsdl.exe tool.如果我尝试使用 wsdl.exe 工具生成代理类,我也会遇到同样的错误。

I can confirm the web service is operating as it should as I can connect to via 3rd part tools such as the SOAPUi client.我可以确认 Web 服务正常运行,因为我可以通过 SOAPUi 客户端等第 3 部分工具进行连接。

Am I missing somehing simple?我错过了一些简单的东西吗?


I have since found the following post: http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/37c376a3-f50c-4b57-a1df-83dc43fcddbf我已经找到以下帖子: http : //social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/37c376a3-f50c-4b57-a1df-83dc43fcddbf

While it describes my issue exactly, I am not sure I understand the solution.虽然它准确地描述了我的问题,但我不确定我是否理解解决方案。 Is anyone able to clarify?有没有人能澄清一下?

(From the MSDN Forums referenced above) (来自上面引用的 MSDN 论坛)

Scenario:设想:

Local side: Asp.net 2.0 Web Service, IIS 6.0本地端:Asp.net 2.0 Web Service、IIS 6.0

Remote side: Java Web Services, Apache, Local ssl certificate(https)远程端:Java Web Services、Apache、本地 ssl 证书(https)

Solution:解决方案:

In short, the problem was when the web service tried to connect to establish the ssl handshake, by default uses TLS and in this case the java web services was SSLv3, but the error never showed this in plain text.简而言之,问题在于当 web 服务尝试连接以建立 ssl 握手时,默认情况下使用 TLS,在这种情况下,java web 服务是 SSLv3,但错误从未以纯文本形式显示。

In order to config this you have set to:为了配置它,您已设置为:

System.Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Ssl3 System.Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Ssl3

After this the service will do the hand shake and continue.在此之后,服务将握手并继续。

In the end I downloaded Visual Studio 2010 trial and it guess what it worked!最后,我下载了 Visual Studio 2010 试用版,猜猜它是怎么工作的!

Don't ask me why.不要问我为什么。

Too old, but in case someone else is struggling, here is another try that worked for me in legacy code:太旧了,但如果其他人正在挣扎,这里是另一个在遗留代码中对我有用的尝试:

System.Net.ServicePointManager.SecurityProtocol = (System.Net.SecurityProtocolType)3072;

This is TLS 1.2, but the value does not exist in the enumeration in .NET 2.0.这是 TLS 1.2,但该值在 .NET 2.0 的枚举中不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM