如何从 Web 服务请求/响应中删除链接引用

发布于 2025-01-08 04:45:24 字数 799 浏览 1 评论 0 原文

我有一个带有用 Java 编写的客户端的 Web 服务。该服务在防火墙后面工作,如果 java 客户端想要使用该服务,则其请求将被阻止,因为该请求包含链接。因此请求包含如下验证器引用:

...<S:Envelope xmlns:S="http://schemas.xmlsoap.org/wsdl/"...

我应该在 wsdl 文件中修复它吗?这是包含此链接的唯一位置:

<definitions targetNamespace="http://mycompany.com/" name="RentalServiceService"
             xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy"
             xmlns:tns="http://mycompany.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"

如果我从 wsdl 文件在 .net 中生成客户端,那么它不会将任何链接引用放入请求中... 谢谢 佐尔坦

I have a web service with a client written in Java. The service works behind a firewall and if the java client wants to consume the service, then its request is blocked because the request contains links. So the request contains validator references like this:

...<S:Envelope xmlns:S="http://schemas.xmlsoap.org/wsdl/"...

Shall I fix it in the wsdl file? That is the only place which contains this link:

<definitions targetNamespace="http://mycompany.com/" name="RentalServiceService"
             xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy"
             xmlns:tns="http://mycompany.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"

If I generate a client in .net from the wsdl file, then it does not put any link references into the request...
Thanks
Zoltan

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

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

发布评论

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

评论(1

空宴 2025-01-15 04:45:24

不要从 XML 消息中删除命名空间。请配置您的防火墙!

通常,SOAP 对防火墙很友好,因为它搭载在 HTTP 之上。如果您从 XML 中删除命名空间,您可能会通过防火墙获得它,但必须使用该消息的 Web 服务可能无法解析它,因为您从中删除了命名空间。 XML 命名空间非常重要,因为它们可以正确识别消息中每个元素所属的域。

作为观察, 是某种复制粘贴错误?... .或者也许是问题的一部分? SOAP 信封的命名空间对于 SOAP 1.1 应为 http://schemas.xmlsoap.org/soap/envelope/http://www.w3.org/2003/05/ SOAP 1.2 的肥皂信封

除此之外,如果 SOAP 消息格式正确,它应该可以通过防火墙。如果没有,那么解决方案是正确配置防火墙并且不要扰乱 SOAP 消息。您的网络管理员应该花时间了解 Web 服务安全性并正确配置防火墙。

我的建议是保留端口 80 仅用于用户来自浏览器的请求/响应,并通过正确的配置在不同的端口号上公开服务。也许您甚至可以在 反向代理 .wikipedia.org/wiki/DMZ_%28computing%29" rel="nofollow">DMZ 提高 Web 服务安全性。这样,您就不会将内部 Web 服务服务器直接暴露到 Internet。

Don't remove namespaces from the XML message. Configure your firewall instead!

Normally, SOAP is friendly with firewalls because it piggybacks on top of HTTP. If you remove the namespaces from the XML you might get it through the firewall but the web service that must make use of the message might fail to parse it because you removed the namespaces from it. XML namespaces are important because they correctly identify the domain to which each element inside the message belongs to.

Just as an observation, the <S:Envelope xmlns:S="http://schemas.xmlsoap.org/wsdl/"... is a copy paste error of some sort?... or maybe part of the problem?! The namespace for the SOAP envelope should be http://schemas.xmlsoap.org/soap/envelope/ for SOAP 1.1 or http://www.w3.org/2003/05/soap-envelope for SOAP 1.2.

That aside, if the SOAP message is correctly formatted, it should pass through the firewall. If it doesn't, then the solution is to configure the firewall properly and not mess with the SOAP message. Your network administrators should spend time understanding web services security and properly configure the firewall.

My suggestion would be to keep port 80 just for your users requests/responses from browsers and expose the service on a different port number with proper configurations. Maybe you could even set up a reverse proxy inside a DMZ to improve the web service security. With that, you won't expose your internal web service server directly to the Internet.

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