WebClient UploadValues UTF-8

G

Guest

We are using the UploadValues function to post a xml string to a java web
service. This has been working well for us be we are running into an issue
with using Western European characters. The service is telling us that they
are receiving "junk" in place of the European characters. We have traced
through our code and it we have verified that it is working correctly all the
way up to when we call this function. Unfortunately, so far we have been
unable to see what is being sent. My question is, can this function be
causing the characters to somehow be translated into "junk"? From my reading
it uses UTF-8 internall and therfor should not be causing a problem. Thanks
for any help!

Ken
 
G

George

I am not sure that my suggestion applies to your scenario. You did not provide enough info.

Here is what i have.
We have a service that returns XML as a string back to the caller. Our XML was generated from the object using XmlSerializer.

And we had similar situation like you have, we have been loosing European characters.
The problem was in the string itself.
Unfortunately XmlSerilaizer is using default encoding and you can not change it.

Here is a workaround.

---------------------
StringWriterWithEncoding sr = new StringWriterWithEncoding();
sr.SetEncoding(System.Text.ASCIIEncoding.UTF8);
XmlSerializer writeSerializer = new XmlSerializer(typeof(YOUROBJECT));
writeSerializer.Serialize(sr, doc);
--------------------------------------------------

public class StringWriterWithEncoding : StringWriter
{
private System.Text.Encoding _encoding = null;
public StringWriterWithEncoding()
{
}

public void SetEncoding( System.Text.Encoding encoding)
{
_encoding = encoding;
}

public override System.Text.Encoding Encoding
{
get
{
if( _encoding != null )
return _encoding;
else
return base.Encoding;
}
}

}


George.




We are using the UploadValues function to post a xml string to a java web
service. This has been working well for us be we are running into an issue
with using Western European characters. The service is telling us that they
are receiving "junk" in place of the European characters. We have traced
through our code and it we have verified that it is working correctly all the
way up to when we call this function. Unfortunately, so far we have been
unable to see what is being sent. My question is, can this function be
causing the characters to somehow be translated into "junk"? From my reading
it uses UTF-8 internall and therfor should not be causing a problem. Thanks
for any help!

Ken
 
J

Joerg Jooss

Ken said:
We are using the UploadValues function to post a xml string to a java
web service. This has been working well for us be we are running
into an issue with using Western European characters. The service is
telling us that they are receiving "junk" in place of the European
characters. We have traced through our code and it we have verified
that it is working correctly all the way up to when we call this
function. Unfortunately, so far we have been unable to see what is
being sent. My question is, can this function be causing the
characters to somehow be translated into "junk"? From my reading it
uses UTF-8 internall and therfor should not be causing a problem.
Thanks for any help!

Does the receiving end really use UTF-8?

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top