473,614 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Deserialize SoapService's reponse message

Hi All,

I need to Deserialize the SoapService's SoapEnvelope response object.

Here is the Body of the SoapEnvelope received as respone,
<q1:serviceResp onse xmlns:q1="urn:C allSetup"><serv iceReturn
xsi:type="q1:re sponse"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance">ok</serviceReturn></q1:serviceRespo nse>
When i try to deserialize with the same class from the client, I'm
receiving the following error,
There is an error in XML document (1, 2).
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader, String encodingStyle, XmlDeserializat ionEvents events)
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader, String encodingStyle)
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(Stream stream)

The source code is given below,
try
{
CS.response myObject;
XmlSerializer mySerializer = new
XmlSerializer(t ypeof(CS.respon se));

byte[] b =
System.Text.Enc oding.Unicode.G etBytes(respons e.Body.InnerXml );
System.IO.Memor yStream ms = new MemoryStream(b) ;

myObject = (CS.response)my Serializer.Dese rialize(ms);

}
catch (Exception ex)
{
Console.WriteLi ne(ex.Message);
Console.WriteLi ne(ex.StackTrac e);

}

This above function works fine, if the XML data is as serialized
<?xml version="1.0" encoding="utf-16"?><response> ok</response>

Is there any way to Deserialize the SoapEnvelope from the soapservice?

Aug 7 '06 #1
4 4638
Hi Anbu,

Are you using WSE ?. The Microsoft.Web.S ervices3.SoapEn velope class has a
method to deserialize the body element.

CS.response myObject =
(CS.response)re sponse.GetBodyO bject(typeof(CS .response));

Regards,
Pablo Cibraro
http://weblogs.asp.net/cibrax
"Anbu" <An************ *****@gmail.com wrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Hi All,

I need to Deserialize the SoapService's SoapEnvelope response object.

Here is the Body of the SoapEnvelope received as respone,
<q1:serviceResp onse xmlns:q1="urn:C allSetup"><serv iceReturn
xsi:type="q1:re sponse"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance">ok</serviceReturn></q1:serviceRespo nse>
When i try to deserialize with the same class from the client, I'm
receiving the following error,
There is an error in XML document (1, 2).
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader, String encodingStyle, XmlDeserializat ionEvents events)
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader, String encodingStyle)
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(Stream stream)

The source code is given below,
try
{
CS.response myObject;
XmlSerializer mySerializer = new
XmlSerializer(t ypeof(CS.respon se));

byte[] b =
System.Text.Enc oding.Unicode.G etBytes(respons e.Body.InnerXml );
System.IO.Memor yStream ms = new MemoryStream(b) ;

myObject = (CS.response)my Serializer.Dese rialize(ms);

}
catch (Exception ex)
{
Console.WriteLi ne(ex.Message);
Console.WriteLi ne(ex.StackTrac e);

}

This above function works fine, if the XML data is as serialized
<?xml version="1.0" encoding="utf-16"?><response> ok</response>

Is there any way to Deserialize the SoapEnvelope from the soapservice?

Aug 7 '06 #2

Pablo,

Thanks for your reply. Unfortunately, it thows an error saying "There
is an error in the XML document".

Stack Trace:
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader, String encodingStyle, XmlDeserializat ionEvents events)\r\n
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader, String encodingStyle)\ r\n at
System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader)\r\n at
Microsoft.Web.S ervices3.SoapEn velope.GetBodyO bject(Type bodyType,
String defaultNamespac e)\r\n at
Microsoft.Web.S ervices3.SoapEn velope.GetBodyO bject(Type bodyType)\r\n
at ....

But the soap envelope is as received from the web service. No changes
made. The return data type of the web service is an Enumerator.

Is there any other way to implement?

Thanks,

Aug 7 '06 #3
So, the type you are using on the client is not the same as the type in the
response message. How did you do to generate the type on the client ? Are
you using the types created with the ws proxy ?.

Regards,
Pablo.

"Anbu" <An************ *****@gmail.com wrote in message
news:11******** *************@7 5g2000cwc.googl egroups.com...
>
Pablo,

Thanks for your reply. Unfortunately, it thows an error saying "There
is an error in the XML document".

Stack Trace:
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader, String encodingStyle, XmlDeserializat ionEvents events)\r\n
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader, String encodingStyle)\ r\n at
System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader)\r\n at
Microsoft.Web.S ervices3.SoapEn velope.GetBodyO bject(Type bodyType,
String defaultNamespac e)\r\n at
Microsoft.Web.S ervices3.SoapEn velope.GetBodyO bject(Type bodyType)\r\n
at ....

But the soap envelope is as received from the web service. No changes
made. The return data type of the web service is an Enumerator.

Is there any other way to implement?

Thanks,

Aug 8 '06 #4
Pablo,

Thanks for your follow-up.

Type of client is same as the server application's return type. Of
course, it's generated from the Webservice's wsdl file. But the web
service adds few namespaces in the response body. This causes the
problem.

To duplicate the same error, create a simple web service site like
HelloWorld, and see the description page of the method (not the WSDL).
There are two entries, one for Soap Post and another one for HTTP post.
The client application was able to recoganize the data if it's in HTTP
Post (response) format, but not Soap response's body.

I think XML deserialization can mainly used with the text files which
are serializable using the classes.

Any thoughts?

Aug 9 '06 #5

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

Similar topics

4
1818
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 as input and deserializes it "into itself" ... in other words I'd like it to "fill" the instance of class A on which the method has been called instead of returning another instance of class A. The code below gives a good idea of what I'd like:
3
65089
by: Mullin Yu | last post by:
I want to know how can i deserialize an object to a string, instead of a file as below:ShoppingList myList = new ShoppingList(); myList.AddItem( new Item( "eggs",1.49 ) ); myList.AddItem( new Item( "ground beef",3.69 ) ); myList.AddItem( new Item( "bread",0.89 ) ); // Serialization XmlSerializer s = new XmlSerializer( typeof( ShoppingList ) ); TextWriter w = new StreamWriter( @"c:\list.xml" ); s.Serialize( w, myList );
2
9528
by: Greg | last post by:
I'm writing a class in C# .... I have a collection calls Reports made up of Report objects. I'm trying to deserialize an XML file that looks like : <Reports> <Report> <Title>some title</Title> <Notes> some notes </Notes> </Report> <Report> blah blah blah </Report>
3
5878
by: Amsteel | last post by:
I got something like this in VB.Net <Serializable()> Public Class YQProfileC Inherits CollectionBase Public Sub Save2File(ByVal FileName As String) Dim IFormatter As New BinaryFormatter() Dim FS As FileStream = New FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.None) IFormatter.Serialize(FS, Me) FS.Close()
4
3241
by: Richard | last post by:
Hello, I'm dynamically writing out a web page using response.write. The page has images and hyperlinks (each hyperlink points back to the same page, but with a different parameter which specifies a larger image that is loaded). When I first bring up the page everything is fine. Then when I click on the hyperlinks, the page reloads but has the exact same images. The only way to view the new images is to hit 'REFRESH'. Is there...
0
4077
by: Matt S | last post by:
Hello, I'm trying to build a C# client to consume an AXIS Web Service (running SOAP over HTTP). The Web Service encodes full server-side exception traces in the Soap Fault > Detail element using complex type structures declared in the WSDL file.
0
918
by: Sylvain | last post by:
Hi, For my new project, I have to implement web services over TCP. After browsing the web, I found out that one of the solutions was to inherit from SoapService class of WSE2.0 and to run it outside IIS. However, I have not been able to found out how scalable this solution is in terms of number of threads available, size of the request pool, etc... and how to configure these properties. Does anybody know?
2
11530
by: Thomas S | last post by:
Any suggestions on how to deserialize an object from one line of XML? I'm trying to deserialize multiple objects from one XML document, each object on one line of the file. The serialization is working, but when I try to read the line back into a MemoryStream, and then to deserialize from that, I get an error that the root node doesn't exist. Example XML lines: <?xml version="1.0"?><LogItem
4
1696
by: Anbu | last post by:
Hi All, I need to Deserialize the SoapService's SoapEnvelope response object. Here is the Body of the SoapEnvelope received as respone, <q1:serviceResponse xmlns:q1="urn:CallSetup"><serviceReturn xsi:type="q1:response" xmlnssi="http://www.w3.org/2001/XMLSchema-instance">ok</serviceReturn></q1:serviceResponse>
0
8198
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8142
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8642
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8591
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8444
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7115
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2575
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 we have to send another system
1
1758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.