jliao

Hi All,
There is a WCF Web Services which will echo binary array as string with UTF-16 encoding.
(Service URL: http://131.107.72.15/MTOM_Service_Indigo/Soap11MtomUtf16.svc;Operation Name: EchoBinaryAsString). The client side which is based on Java StAX XML parser always fail on parsing the following response from WCF, but I test it with WCF client and it works.

200 OK
X-Powered-By: ASP.NET
Content-Length: 843
X-AspNet-Version: 2.0.50727
null: HTTP/1.1 200 OK
Date: Fri, 01 Jun 2007 05:03:59 GMT
Server: Microsoft-IIS/6.0
Content-Type: multipart/related; type="application/xop+xml";start="
http://tempuri.org/0>";boundary="uuid:7bf3c54c-1080-4185-a952-196721d0726c+id=5
;start-info="text/xml"
MIME-Version: 1.0
Cache-Control: private
--uuid:7bf3c54c-1080-4185-a952-196721d0726c+id=5
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: binary
Content-Type: application/xop+xml;charset=utf-16LE;type="text/xml"
< xml version="1.0" encoding="utf-16" >
<s:Envelope xmlnsTongue Tied="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<EchoBinaryAsStringResponse xmlns="http://xmlsoap.org/Ping">
<EchoBinaryAsStringResult>&#x0;a&#x0;b&#x0;cV9V;</EchoBinaryAsStringResult>
</EchoBinaryAsStringResponse>
</s:Body>
</s:Envelope>
--uuid:7bf3c54c-1080-4185-a952-196721d0726c+id=5--

Could someone tell me how to interop with such an WCF web services from Java


Re: Windows Communication Foundation (Indigo) Encounter Illegal XML character: &#x0; while calling a WCF Web Services

Brian McNamara - MSFT

At first glance, this looks like a bug in WCF and/or the .Net XML stack.

I'll follow up and let you know.






Re: Windows Communication Foundation (Indigo) Encounter Illegal XML character: &#x0; while calling a WCF Web Services

jliao

My input byte array is constructed by the following Java code:
private static final String S = "abc\u5639\u563b";
byte[] input = S.getBytes("UTF-16");




Re: Windows Communication Foundation (Indigo) Encounter Illegal XML character: &#x0; while calling a WCF Web Services

James Osborne - MSFT

Can you post the WCF client code which successfully parses this invalid xml

-James





Re: Windows Communication Foundation (Indigo) Encounter Illegal XML character: &#x0; while calling a WCF Web Services

jliao

James,
WCF client code:
IMtomTest client = new MtomTestClient();
byte[] bArray = new byte[] { 0, 97, 0, 98, 0, 99, 86, 57, 86, 59 };
String ret = client.EchoBinaryAsString(bArray);
Console.Write("Return String: " + ret);
Console.WriteLine();
foreach (byte a in ret)
Console.Write("= "+ a);
string r = ret;
Console.WriteLine("Press <ENTER> to terminate client.");
Console.ReadLine();

Snippet of log file:
<s:Envelope xmlnsTongue Tied="http://schemas.xmlsoap.org/soap/envelope/"><s:Header></s:Header><s:Body><EchoBinaryAsStringResponse xmlns="http://xmlsoap.org/Ping"><EchoBinaryAsStringResult>&#x0;a&#x0;b&#x0;cV9V;</EchoBinaryAsStringResult></EchoBinaryAsStringResponse></s:Body></s:Envelope>

thanks,
-LJ






Re: Windows Communication Foundation (Indigo) Encounter Illegal XML character: &#x0; while calling a WCF Web Services

James Osborne - MSFT

Thanks. This is a bug which we are tracking and aim to have fixed in the Orcas release.

-James





Re: Windows Communication Foundation (Indigo) Encounter Illegal XML character: &#x0; while calling a WCF Web Services

James Osborne - MSFT

It turns out this is the intended design.

Having the byte 0 and $#x0; are semantically equivalent in XML, and the first one is invalid, so the second one should be invalid as well. However, we still need a way to encode string values that are valid CLR strings. If we disallowed those invalid XML chars (which also include '\uFFFE' and '\uFFFF') WCF would not be able to pass the string "Hello\u0000world" to a simple Echo(string) method.

So, what was done was that WCF would "entitize" those invalid XML chars, so that the reader could decode them. If we didn't escape the \u0000 character, we'd have invalid XML per its definition. By escaping it, we're allowing some readers to be able to consume it.

HTH,

James





Re: Windows Communication Foundation (Indigo) Encounter Illegal XML character: &#x0; while calling a WCF Web Services

jliao

Would this change get reflect at Web Services Interop Plug-fest ¨C 10-12 July 2007 Have endpoint(http://131.107.72.15/MTOM_Service_Indigo/Soap11MtomUtf16.svc) updated now

-LJ





Re: Windows Communication Foundation (Indigo) Encounter Illegal XML character: &#x0; while calling a WCF Web Services

James Osborne - MSFT

AFAIK, nothing is getting changed, since this is the intended behavior.

-James





Re: Windows Communication Foundation (Indigo) Encounter Illegal XML character: &#x0; while calling a WCF Web Services

jliao

ok, will avoid sending such character.

Thanks