"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
Mike Schilling <ap@newsgroup.nospamwrote:
<snip>
>And I can parse the same file locally and observe that it's correct (e.g.
with the program below). It only acts oddly when processed by the web
service.
That's pretty odd :(
I've passed non-ASCII characters in web services before with no
problems... this is very odd.
Do you have a solution with just a web service and just a test app that
I could have a look at?
Here's the web service:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace HexString
{
public class Service1 : System.Web.Services.WebService {
public Service1() {
InitializeComponent();
}
private IContainer components = null;
private void InitializeComponent() { }
protected override void Dispose( bool disposing ) {
if(disposing && components != null) {
components.Dispose();
}
base.Dispose(disposing);
}
[WebMethod]
public string ToHex(String s) {
String ret = "";
for (int i = 0; i < s.Length; i++) {
ret += "0x" + ((int)s[i]).ToString("X");
if (i < s.Length - 1)
ret += ", ";
}
return ret;
}
}
}
and here is the client
using System;
using System.Text;
using System.Net;
namespace HexStringClient {
class Client {
[STAThread]
static void Main(string[] args) {
WebClient wc = new WebClient();
byte[] bytes = Encoding.GetEncoding("iso-8859-1").GetBytes(doc);
try {
wc.Headers.Add("SOAPAction", "\"http://tempuri.org/ToHex\"");
wc.Headers.Add("content-type", "text/xml");
byte [] response =
wc.UploadData("http://localhost/HexString/Service1.asmx",
"POST", bytes);
Console.Out.WriteLine(Encoding.ASCII.GetString(res ponse));
}
catch (Exception ex) {
Console.Out.WriteLine(ex);
}
}
static String doc =
"<?xml version='1.0' encoding='iso-8859-1'?>\n" +
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"
+
"xmlns:xsd='http://www.w3.org/2001/XMLSchema'\n" +
"xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>\n" +
"<soap:Body>\n" +
"<ToHex xmlns='http://tempuri.org/'>\n" +
" <s>a\u00e9\u00ec\u00e6f</s>\n" +
"</ToHex>\n" +
"</soap:Body>\n" +
"</soap:Envelope>";
}
}