views:

177

answers:

1

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?

A: 

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.

Colin Dijkgraaf