VB.NET Web 服务客户端访问 Java Web 服务 - 连接中止

发布于 2024-09-24 19:02:47 字数 966 浏览 1 评论 0原文

我在让 VB.NET Web 服务客户端接收来自 Java Web 服务的响应对象时遇到问题。在发布这个问题的过程中,另一个部门的某人自愿提供了一些为类似情况编写的代码。我在网上找不到这个问题,所以我正在完成我的问题以帮助其他人。

Dim myService As New theService.TheService()
Dim objCurrentPrice As New myService.CurrentPrice

myService.Credentials = New NetworkCredential("webuser", "123pass")

objCurrentPrice = myService.getCurrentPrice("10211012343")
MessageBox.Show(objCurrentPrice.Description)

失败于:

objCurrentPrice = myService.getCurrentPrice("10211012343")

内部异常表明连接被远程主机中止。

这是我的同事提供的带有附加行的代码:

Dim myService As New theService.TheService()
Dim objCurrentPrice As New myService.CurrentPrice

myService.Credentials = New NetworkCredential("webuser", "123pass")
ServicePointManager.Expect100Continue = False

objCurrentPrice = myService.getCurrentPrice("10211012343")
MessageBox.Show(objCurrentPrice.Description)

它解决了互操作性问题。 Web 服务是 Apache CXF,其中混合了一些 Spring 元素。

I had a problem getting a VB.NET web service client to receive the response object from a Java web service. In the process of posting this question someone from another department volunteered some code written for a similar situation. I couldn't find this anywhere on the net so I'm completing my question to help others out.

Dim myService As New theService.TheService()
Dim objCurrentPrice As New myService.CurrentPrice

myService.Credentials = New NetworkCredential("webuser", "123pass")

objCurrentPrice = myService.getCurrentPrice("10211012343")
MessageBox.Show(objCurrentPrice.Description)

This failed at:

objCurrentPrice = myService.getCurrentPrice("10211012343")

With the inner exception stating the connection was aborted by the remote host.

Here is the code with the additional line that my co-worker gave:

Dim myService As New theService.TheService()
Dim objCurrentPrice As New myService.CurrentPrice

myService.Credentials = New NetworkCredential("webuser", "123pass")
ServicePointManager.Expect100Continue = False

objCurrentPrice = myService.getCurrentPrice("10211012343")
MessageBox.Show(objCurrentPrice.Description)

Which fixed the interoperability problem. The web service is Apache CXF with some Spring elements mixed in.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

古镇旧梦 2024-10-01 19:02:47

像这样修改这个静态变量:

ServicePointManager.Expect100Continue = False

Modify this static variable like this:

ServicePointManager.Expect100Continue = False
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文