473,379 Members | 1,355 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,379 software developers and data experts.

Serializing RTF during a web method call

I've seen this topic several times in archives, but I have not come across a
workable solution. I'm stuck in 1.1 for a project (although I can tack on
any WSE that still targets it), and I've got a class that stores some RTF in
some of its fields. RTF has an issue in that by definition, it includes a
null (/0) character, which does not encode well to UTF-8. Throughout my UI,
I can deserialize/serialize just fine because I use the
XmlTextReader/Writer, which does its magic to make sure that isn't a
problem. However, when I call my web method, the encoding is stuck at
UTF-8. I can set the service proxy's RequestEncoding to whatever I want, but
because the web service itself is using UTF8 (and as best I can tell, I
cannot change that), I cannot consume the web service.

It's been a while (and several releases) since 1.1's been out, so I was
wondering if in that time, someone's come up with a decent solution to this
within the confines of 1.1 (and the WSE family)
Feb 13 '07 #1
3 1620
"Keith Patrick" <ri*******************@nospam.hotmail.comwrote in message
news:eA**************@TK2MSFTNGP06.phx.gbl...
I've seen this topic several times in archives, but I have not come across
a workable solution. I'm stuck in 1.1 for a project (although I can tack
on any WSE that still targets it), and I've got a class that stores some
RTF in some of its fields. RTF has an issue in that by definition, it
includes a null (/0) character, which does not encode well to UTF-8.
Throughout my UI, I can deserialize/serialize just fine because I use the
XmlTextReader/Writer, which does its magic to make sure that isn't a
problem. However, when I call my web method, the encoding is stuck at
UTF-8. I can set the service proxy's RequestEncoding to whatever I want,
but because the web service itself is using UTF8 (and as best I can tell,
I cannot change that), I cannot consume the web service.

It's been a while (and several releases) since 1.1's been out, so I was
wondering if in that time, someone's come up with a decent solution to
this within the confines of 1.1 (and the WSE family)
If it's your web method, try sending the RTF as an array of bytes.

John
Feb 13 '07 #2
That would be a bit difficult. The structure I am sending is hierarchical
with 4 child objects, 2 of which have 3 RTF fields, and the other 2 with 2
RTFs plus a child with 3 RTFs. Is there some way to tell the serializer to
serialize just those fields as binary, or does it have to be done at the web
service level?

Feb 13 '07 #3
Here's a working solution I came up with. It's not as good as specifying an
encoder in the service, but it does a similar thing. Basically, I tagged my
class (Note)'s .Value property with XmlIgnore (used to be XmlText), and then
tweaked it until it looked like this:
[XmlIgnore]
public String Value
{
get
{
String value = this.Utf8Value;
return value == null ? null :
Encoding.UTF7.GetString(Encoding.UTF8.GetBytes(val ue));
}
set
{
this.Utf8Value = value == null ? null :
Encoding.UTF8.GetString(Encoding.UTF7.GetBytes(val ue));
}
}

/// <summary>
///
/// </summary>
[XmlText]
public String Utf8Value
{
get
{
return this._Value;
}
set
{
this._Value = value;
}
}
So basically, I'm telling the serializer to use an internal, UTF8-safe
property, while my RTFs interact with an an encoding/decoding facade
property.
Feb 13 '07 #4

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

Similar topics

10
by: copx | last post by:
I want to save a struct to disk.... as plain text. At the moment I do it with a function that just writes the data using fprintf. I mean like this: fprintf(fp, "%d %d", my_struct.a, my_struct.b)...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
0
by: markoueis | last post by:
What data type does not need to be serialized? I would like to do the serialization myself and then call a web method that would take the serialized stream "as is", without any further...
1
by: Aidan Glendye | last post by:
Hi, I am trying to store various objects within session. Due to the site being hosted in a web farm we are going to have to use either State Server or SQL Server to persist the data in...
8
by: Joe | last post by:
Hello All: Say I have a solution with two projects (Project1 and Project2) and each project contains a class (Project1 contains Class1 and Project2 contains Class2). The projects don't...
4
by: Charles Law | last post by:
Two questions really: 1. Can an object de-serialise itself? I use XMLSerializer and the Deserialize method to read an XML file and return an object of my given type. The code that does this...
3
by: RandomEngineer | last post by:
So here's the challenge... How can a collection (System.Collections.Generic.IList) of some custom type be serialized in a web service using .NET 2.0? Below are the class and the web methods in...
6
by: Kyle Teague | last post by:
What would give better performance, serializing a multidimensional array and storing it in a single entry in a table or storing each element of the array in a separate table and associating the...
5
by: | last post by:
I've got a basic "chat" infrastructure that can send objects across the wire, but I'm running into a few issues with trying to send multiple messages and things behaving differently in debug and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.