SAXParseException:元素类型 SOAP:Text 后面必须跟有属性规范“>”或“>”。或“/>”

发布于 2024-10-01 10:37:06 字数 1022 浏览 5 评论 0原文

我正在尝试读取 Eclipse Galileo 中运行的 junit 测试中的 Web 服务调用的响应。我能够成功接收响应,除非响应是 SOAP 错误。然后我得到以下异常: org.xml.sax.SAXParseException:元素类型“SOAP:Text”后面必须跟有属性规范“>”或“/>”

我已在 LiquidXML Studio 中根据 SOAP 1.2 架构验证了 XML,并且它已通过检查。

下面是 SAX 似乎令人窒息的 XML 响应。它已被剥离到最低限度,试图消除任何明显的东西(我什至确保它没有任何自关闭元素):

<肥皂:主体>SOAP:发送者SOAP:发送者<肥皂:原因>

如有任何帮助,我们将不胜感激。

I'm attempting to read a response from a web service call in a junit test running in Eclipse Galileo. I'm able to successfully receive responses except when the response is a SOAP fault. Then I get the following exception:
org.xml.sax.SAXParseException: Element type "SOAP:Text" must be followed by either attribute specifications, ">" or "/>"

I have validated the XML in LiquidXML Studio against the SOAP 1.2 schema and it checks out.

Here is the XML response that SAX appears to be choking on. It has been stripped to the minimum in an attempt to eliminate anything obvious (I even made sure it didn't have any self closing elements):

<SOAP:Envelope xmlns:SOAP="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP_ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP:Header>
</SOAP:Header>
<SOAP:Body>
<SOAP:Fault>
<SOAP:Code>
<SOAP:Value>SOAP:Sender</SOAP:Value>
<SOAP:Subcode>
<SOAP:Value>SOAP:Sender</SOAP:Value>
</SOAP:Subcode>
</SOAP:Code>
<SOAP:Reason>
<SOAP:Text xml:lang="">
</SOAP:Text>
</SOAP:Reason>
<SOAP:Node>
</SOAP:Node>
<SOAP:Role>
</SOAP:Role>
<SOAP:Detail>
</SOAP:Detail>
</SOAP:Fault>
</SOAP:Body>
</SOAP:Envelope>

Any help would be appreciated.

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

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

发布评论

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

评论(3

机场等船 2024-10-08 10:37:06

它显然没有将 'xml:lang=""' 识别为属性。检查您的 xsd 或 xmlSchema 哪些属性是有效的。另外,您应该使用

xml:lang=""

而不是“”,尽管大多数解析器会原谅您这样做。

Its obviously not regcognising 'xml:lang=""' as an attribute. CHeck with your xsd or xmlSchema what attributes are valid. Also you should be using

xml:lang=""

rather than "" although most parsers forgive you for this.

§普罗旺斯的薰衣草 2024-10-08 10:37:06

我认为问题在于将肥皂故障 xml 映射到其相应的对象。

I think the problem is in mapping the soap fault xml to its corresponding object.

放手` 2024-10-08 10:37:06

事实证明,问题与我用来返回 Web 服务请求的静态字符串响应的工具有关。静态响应 XML 包含 xml:lang 属性。然而,当该工具返回静态字符串时,它会在退出时对其进行修改,并将 xml:lang 动态替换为等效的完全限定命名空间 {http://www.w3.org/XML/1998/命名空间}lang.当收到此响应时,SAXParser 感到窒息,因为它无法解释完全限定的等效内容。

返回静态响应的工具使用 Groovy xml 解析器作为发送响应的组成部分。
XmlParser Groovy 类有一个构造函数,我必须更改该构造函数才能将验证和命名空间感知属性设置为 false。因此,该工具现在调用 XmlParser(false, false),而不是 XmlParser()。
问题解决了。
感谢您的回复。

It turns out the problem was related to a tool I was using to return static string responses to web service requests. The static response XML contained the xml:lang attribute. However, when the tool was returning the static string, it was modifying it on the way out and replacing xml:lang on-the-fly with the fully qualified namespace equivalent {http://www.w3.org/XML/1998/namespace}lang. When this response was received, the SAXParser was choking because it couldn't interpret the fully qualified equivalent.

The tool returning the static responses used a Groovy xml parser as an integral part of sending the response.
The XmlParser Groovy class has a constructor that I had to change to set validating and namespaceAware attributes to false. So instead of XmlParser(), the tool now calls XmlParser(false, false).
Problem solved.
Thanks for the responses.

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