473,503 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to send a XmlSerializer Class to a WebService and then Deserialize it?

2 New Member
Hi!

I want to be able to send a XmlSerializer class (which is generated obvious in remote C# application) over a WebService that will then deserialize it into a class. (I didnt know it its possible either)

My class is:

Expand|Select|Wrap|Line Numbers
  1. SystemInfo
I'm serializing it this way:
Expand|Select|Wrap|Line Numbers
  1. XmlSerializer mySerializer = new XmlSerializer(typeof(SystemInfo));
  2. StreamWriter myWriter = new StreamWriter(textBox1.Text);
  3. mySerializer.Serialize(myWriter, sysinfo);
How can i build the WebService?

Expand|Select|Wrap|Line Numbers
  1.     [WebMethod]
  2.     public void Reports(XmlSerializer xmlSerializer)
  3.     {
  4.       .
  5.       .
  6.       .
  7.     }
Can anyone help me out?

Regards
May 29 '10 #1
1 2213
pee2002
2 New Member
Never mind.. i solved already.

The only thing i need to send is the xml STRING to the webservice.

Web Service:
Expand|Select|Wrap|Line Numbers
  1.         [WebMethod]
  2.         public void Reports(string xml)
  3.         {
  4.             XmlSerializer mySerializer = new XmlSerializer(typeof(SystemInfo));
  5.             SystemInfo obj = (SystemInfo)mySerializer.Deserialize(new StringReader(xml));
  6.         }

Application:

Expand|Select|Wrap|Line Numbers
  1.         private void button2_Click(object sender, EventArgs e)
  2.         {
  3.             SystemInfo sysinfo = new SystemInfo();
  4.             sysinfo.RUN();
  5.  
  6.             XmlSerializer mySerializer = new XmlSerializer(typeof(SystemInfo));
  7.  
  8.             MemoryStream memStream = new MemoryStream();
  9.                 mySerializer.Serialize(memStream, sysinfo);
  10.                 memStream.Seek(0, System.IO.SeekOrigin.Begin);
  11.                 XmlDocument doc = new XmlDocument();
  12.                 doc.Load(memStream);
  13.             memStream.Close();
  14.  
  15.             localhost.WS_Agente dasdsa = new localhost.WS_Agente();
  16.             dasdsa.Reports(doc.InnerXml);
  17.         }
May 29 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1803
by: Bob Rock | last post by:
Hello, I've got an xml stream that I'd need to deserialize into an instance of a given class A. I'd like to create an instance method on class A (method Deserialize) that takes this XML stream...
8
3542
by: Harris Boyce | last post by:
Hello, I'm trying to use the FOR XML EXPLICIT clause with SQL Server to deserialize data from my database into a strongly-typed collection object that I will use throughout my application. I...
2
6792
by: Chris Aitchison | last post by:
Hello, I am attempting to have a class that I have written serialize so that it can be both passed as a parameter or return value for a webservice, and also be serialized to disk using the...
1
4298
by: Bluetears76 | last post by:
Hi I have a hirachy of classes which are Message(base), then FileMessage and ChatMessage (extended) I want to serialize the objects and when i am deserizaling i dont know if i am getting...
0
977
by: Paulo Aboim Pinto | last post by:
Hello I have an hieraquical structure that i can XMLSerialize. Because of perfomace it will be better to serialize node by node like i do when i Deserialize that i can read one node with...
4
11348
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This...
7
4723
by: Just D. | last post by:
All, What's the easiest way to deserialize class from the class itself? Step by step. We create some class, add all required USINGs, make this class serializable, then add a method like: ...
4
5400
by: Ultrakorne | last post by:
hi, i have some problems with my client talk to my server... i am using xmlserializer to serialize object and send them to the other side of the connection. I need to send / recive by both client...
4
18534
by: ad | last post by:
I want to send a DataSet to WebService, but the DataSet if too huge(there about 50000 records, and 50 fields every record). My solution is 1.save the DataSet as XML file, 2.zip the XML file. 3....
2
2142
by: butch77 | last post by:
Hi! We're creating flash websites, and we are now switching over to flash 9. We decided now to use webservices for the front end. And we have already been using webservices for the CMS. Now my...
0
7202
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
7328
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...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.