M
Mullin Yu
I want to submit a utf-8 xml request to a servlet by the following coding.
it seesm that the servlet can't recognize it correctly.
can i just using string postData = "..... utf-8 data" and then save the
files at utf-8 encoded at the vs.net ide?
or if i use string, vs.net ide will conside it to be utf-16???
UTF8Encoding encoding = new UTF8Encoding();
string postData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"urn:schemas-xmlsoap-org:envelope\">" +
"<SOAP-ENV:Header>" +
"<SOAPActionVersion>1.5.5</SOAPActionVersion></SOAP-ENV:Header>" +
"<SOAP-ENV:Body>" +
"<cmEDMSCustomerContactPage transactionType=\"UPDT\">" +
"<cmEDMSCustomerContactPageService>" +
"<cmEDMSCustomerContactPageHeader PageReadSW=\"false\"
CustomerContactID=\"8210710493\"></cmEDMSCustomerContactPageHeader>" +
"<cmEDMSCustomerContactPageDetails>" +
"<LogEntry>" +
"<LogEntryHeader CustomerContactID=\"8210710493\">" +
"</LogEntryHeader>" +
"<LogEntryRow rowAction=\"ADD\" CustomerContactID=\"8210710493\" LogEntry=\"
utf-8 characters \">" +
"</LogEntryRow>" +
"</LogEntry>" +
"</cmEDMSCustomerContactPageDetails>" +
"</cmEDMSCustomerContactPageService>" +
"</cmEDMSCustomerContactPage>" +
"</SOAP-ENV:Body >" +
"</SOAP-ENV:Envelope>";
Console.WriteLine(postData);
byte[] data = encoding.GetBytes(postData);
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create(http://172.18.2.1:7520/server);
myRequest.Method = "POST";
myRequest.ContentType="text/xml";
myRequest.ContentLength = data.Length;
myRequest.SendChunked = true;
myRequest.TransferEncoding = "UTF8";
myRequest.Credentials = new NetworkCredential("CDX", "pwd");
Stream newStream=myRequest.GetRequestStream();
// Send the data.
newStream.Write(data,0,data.Length);
newStream.Close();
it seesm that the servlet can't recognize it correctly.
can i just using string postData = "..... utf-8 data" and then save the
files at utf-8 encoded at the vs.net ide?
or if i use string, vs.net ide will conside it to be utf-16???
UTF8Encoding encoding = new UTF8Encoding();
string postData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"urn:schemas-xmlsoap-org:envelope\">" +
"<SOAP-ENV:Header>" +
"<SOAPActionVersion>1.5.5</SOAPActionVersion></SOAP-ENV:Header>" +
"<SOAP-ENV:Body>" +
"<cmEDMSCustomerContactPage transactionType=\"UPDT\">" +
"<cmEDMSCustomerContactPageService>" +
"<cmEDMSCustomerContactPageHeader PageReadSW=\"false\"
CustomerContactID=\"8210710493\"></cmEDMSCustomerContactPageHeader>" +
"<cmEDMSCustomerContactPageDetails>" +
"<LogEntry>" +
"<LogEntryHeader CustomerContactID=\"8210710493\">" +
"</LogEntryHeader>" +
"<LogEntryRow rowAction=\"ADD\" CustomerContactID=\"8210710493\" LogEntry=\"
utf-8 characters \">" +
"</LogEntryRow>" +
"</LogEntry>" +
"</cmEDMSCustomerContactPageDetails>" +
"</cmEDMSCustomerContactPageService>" +
"</cmEDMSCustomerContactPage>" +
"</SOAP-ENV:Body >" +
"</SOAP-ENV:Envelope>";
Console.WriteLine(postData);
byte[] data = encoding.GetBytes(postData);
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create(http://172.18.2.1:7520/server);
myRequest.Method = "POST";
myRequest.ContentType="text/xml";
myRequest.ContentLength = data.Length;
myRequest.SendChunked = true;
myRequest.TransferEncoding = "UTF8";
myRequest.Credentials = new NetworkCredential("CDX", "pwd");
Stream newStream=myRequest.GetRequestStream();
// Send the data.
newStream.Write(data,0,data.Length);
newStream.Close();