使用 WebRequest 进行 SOAP Web 服务调用

发布于 2024-07-14 21:36:53 字数 301 浏览 2 评论 0原文

我们有一个 ASP.Net Web 应用程序,它调用部署在同一虚拟目录中的 Web 服务。 调用在开发机器上返回没有任何问题。 但当部署到生产服务器时,它会返回“400 Bad Request”错误。 通过创建 WebRequest 并设置 SoapAction 标头来进行调用,然后 WebResponse.GetRepsonseStream() 获取 SOAP 响应。 我们暂时通过使用生成的代理进行调用来解决该问题。

任何人都可以建议使用 WebRequest 和 WebResponse 调用 Web 服务而不会遇到 400 错误的正确方法吗?

We have an ASP.Net web application which calls Web Services deployed in the same virtual directory. The call returns without any problem in the development machine. But when deployed to the production server, it gives back a '400 Bad Request' error. The call was made by creating a WebRequest and setting the SoapAction header and then WebResponse.GetRepsonseStream() gets the SOAP response. Temporarily, we fixed the issue by making the call using the proxy generated.

Can anyone suggest a proper way of calling web services using WebRequest and WebResponse without encountering the 400 error?

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

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

发布评论

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

评论(1

染火枫林 2024-07-21 21:36:53

我不明白你为什么要这样做。 我将添加对服务 WSDL 的 Web 引用,并让框架处理其余的事情! 根据我在 Web 服务和 ASP.NET 方面的经验,这是最简单的方法。

I don't understand why you are doing that way. I would add a web reference to the service WSDL and let the framework take care of the rest! In my experience with web services and ASP.NET, this is the easiest way.

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