wsdl xml解析,文本编码后的maxlength问题
我们正在与另一家公司合作。我们的应用程序通过我们一侧的 WCF 和另一侧的自定义实现的 java wsdl 处理程序与其他应用程序通信。它们指定 wsdl 格式,规则之一是特定字符串不能包含超过 15 个字符。 (通常是 60,但出于简单的示例原因,我采用 15)
当我们尝试将以下字符串发送给他们时,我们收到一个错误,根据 wsdl,该字符串太长:
"example & test">这是一个 14 个字符的字符串,因此应该允许
microsoft wcf 解析器将其转换为 "example & test"
。该编码字符串的长度为 18 个字符。
现在检查消息中定义的最大长度的标准行为是什么?是编码的消息还是解码的消息?我认为这是解码后的消息,但我不确定。如果它是编码消息,我们应该如何处理它,以便我们知道如何分割字符串?
We are working together with another firm. our application communicates with the other application through WCF on our side and a custom implemented java wsdl handler on the other side. They specify the wsdl format and one of the rules is that a specific string cannot contain more then 15 characters. (normally it's 60, but i take 15 for easy example reasons)
When we try to send the following string to them we get an error that the string is too long according to the wsdl:
"example & test"
> this is a string of 14 characters, so it should be allowed
the microsoft wcf parser translates this to "example & test"
. This encoded string is 18 characters long.
Now what is the standaard behavior to check a maxlength defined in a message? Is it the encoded message or the decoded message? I would think it's the decoded message , but i ain't sure. If it is the encoded message, how should we handle this so we would know how we have to split the string?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://www.w3.org/TR/xmlschema-2/# rf-最大长度
4.3.3 maxLength
对于字符串和从字符串派生的数据类型,maxLength 以 [XML 1.0(第二版)]
字符 集中定义的字符为单位进行测量
[定义:已解析的实体包含文本、字符序列,可能表示标记或字符数据。]
读到这一点,我认为标准行为是解码为标记字符应被视为单个字符。
因此,通常在编码之前您会进行任何拆分/截断。
否则,如果截断编码字符的中间,就会遇到问题。
我已经针对带有 BizTalk 的 WCF Web 服务对此进行了测试,对于长度超过 maxLength 的 XML 编码字符串来说效果很好。
听起来他们好像在解码之前就这样做了。
因此,您可能必须先对其进行编码,然后在空白处将其拆分。
http://www.w3.org/TR/xmlschema-2/#rf-maxLength
4.3.3 maxLength
For string and datatypes ·derived· from string, maxLength is measured in units of characters as defined in [XML 1.0 (Second Edition)]
Charsets
[Definition: A parsed entity contains text, a sequence of characters, which may represent markup or character data.]
Reading that I would think the standard behaviour is the decoded as a marked up character should be treated as a single character.
So usually you do any splitting/truncation before you encode it.
Otherwise you run into issues if you truncate through the middle of an encoded character.
I've tested this against a WCF web service with BizTalk behind it and it's fine with an XML encoded string that is longer than the maxLength.
It sounds like they are doing it before the decode it though.
So you may have to encode it first and then split it on the white space.