473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

send big5 xml request to servlet

i try to send a big5-encoded xml request to a java servlet by two ways

1. vb6 => success
2. c# => all chinese character becomes ??????

my c# coding is as following:

i wonder will it convert my big5 chinese to utf-8 or utf-16 already before
sending. any clue and suggestion:

mlDocument xmlDOM = new XmlDocument();

xmlDOM.Load("ryan_big5.xml");
/*

string strXML = xmlDOM.OuterXml;

MessageBox.Show(strXML);

Console.WriteLine("Request: " + strXML);

Byte[] data = System.Text.Encoding.ASCII.GetBytes(strXML.ToStrin g());

*/

Byte[] data = System.Text.Encoding.ASCII.GetBytes(xmlDOM.OuterXm l);

HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("http://172.18.2.1:7520/XAIApp/xaiserver_b
ig5");
myRequest.Method = "POST";

myRequest.ContentType="text/xml; encoding=big5";

myRequest.ContentLength = data.Length;

myRequest.Credentials = new NetworkCredential("CDX", "cordaptix");

Stream newStream = myRequest.GetRequestStream();

// Send the data.

newStream.Write(data,0,data.Length);

newStream.Close();
// Get Response

WebResponse myResponse = myRequest.GetResponse();

StreamReader sr = new StreamReader(myResponse.GetResponseStream());
string response = sr.ReadToEnd();

MessageBox.Show(response);

Console.WriteLine("Response: " + response);


Nov 15 '05 #1
2 2941
Mullin Yu <mu*******@ctil.com> wrote:
i try to send a big5-encoded xml request to a java servlet by two ways
<snip>
Byte[] data = System.Text.Encoding.ASCII.GetBytes(xmlDOM.OuterXm l);
If you want to send Big5 data, why on earth are you converting your XML
into ASCII? You're basically lying to the server when you then say:
myRequest.ContentType="text/xml; encoding=big5";


--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
i found the clue:
Byte[] data =
System.Text.Encoding.GetEncoding("BIG5").GetBytes( xmlDOM.OuterXml);

thanks!

mullin

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Mullin Yu <mu*******@ctil.com> wrote:
i try to send a big5-encoded xml request to a java servlet by two ways


<snip>
Byte[] data = System.Text.Encoding.ASCII.GetBytes(xmlDOM.OuterXm l);


If you want to send Big5 data, why on earth are you converting your XML
into ASCII? You're basically lying to the server when you then say:
myRequest.ContentType="text/xml; encoding=big5";


--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: efiedler | last post by:
Hi - I have the following input field on my html page: <input type="image" name="submit" id="submit" src="c:\image.jpg" value="image.jpg"> I also have another input field on the form that is...
7
by: Mullin Yu | last post by:
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...
2
by: Arti | last post by:
Hi, I am trying to access a servlet hosted on Tomcat server using HTTPS Post protocol. I am getting the exception: "The underlying connection was closed: Could not establish trust relationship...
19
by: roh | last post by:
Hi Folks, We have e-Biz application running on WebSphere Application Server Ver 6.0 using DB2 UDB Ver 8.1 . We are facing following issue in our application , any help from your side will be...
1
by: Vimala Sri | last post by:
Hello all, Have a great day. I wish to made interaction from c program in unix to the java servlet. That is i want to send a request from the Unix c program to the servlet. ...
0
by: panku007 | last post by:
Hi all, I have one jsp page in that page three frames are created and one of three frame, one jsp page is displaying and from that page i want to send request to servlet from one frame...
3
by: vijaykumardahiya | last post by:
Dear Sir, I have two queries. First question is: I have a Html page. On which Have two buttons Submit and Issue. I want when I click on Sumit button request should be go to submit.jsp. and When I...
2
by: btcoder | last post by:
Hi, my jsp page uses sun.net.smtp.SmtpClient to send email. It worked fine until the hosted location was moved to another server. Now it generates the sun.net.smtp.SmtpProtocolException and the...
1
sid0404
by: sid0404 | last post by:
Hi I need to send data from my servlet to my html(which contains AJAX), so as per the motivation of the AJAX, this should be done without my webpage reloading / refresh. my code on the ajax...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.