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

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:serviceResponse xmlns:q1="urn:CallSetup"><serviceReturn
xsi:type="q1:response"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance">ok</serviceReturn></q1:serviceResponse>
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.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Deserialize (Stream stream)

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

byte[] b =
System.Text.Encoding.Unicode.GetBytes(response.Bod y.InnerXml);
System.IO.MemoryStream ms = new MemoryStream(b);

myObject = (CS.response)mySerializer.Deserialize(ms);

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);

}

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 1686
Hi Anbu,

Are you using WSE ?. The Microsoft.Web.Services3.SoapEnvelope class has a
method to deserialize the body element.

CS.response myObject =
(CS.response)response.GetBodyObject(typeof(CS.resp onse));

Regards,
Pablo Cibraro
http://weblogs.asp.net/cibrax
"Anbu" <An*****************@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
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>
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.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Deserialize (Stream stream)

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

byte[] b =
System.Text.Encoding.Unicode.GetBytes(response.Bod y.InnerXml);
System.IO.MemoryStream ms = new MemoryStream(b);

myObject = (CS.response)mySerializer.Deserialize(ms);

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);

}

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.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)\r\n
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle)\r\n at
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader)\r\n at
Microsoft.Web.Services3.SoapEnvelope.GetBodyObject (Type bodyType,
String defaultNamespace)\r\n at
Microsoft.Web.Services3.SoapEnvelope.GetBodyObject (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.comwrote in message
news:11*********************@75g2000cwc.googlegrou ps.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.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)\r\n
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle)\r\n at
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader)\r\n at
Microsoft.Web.Services3.SoapEnvelope.GetBodyObject (Type bodyType,
String defaultNamespace)\r\n at
Microsoft.Web.Services3.SoapEnvelope.GetBodyObject (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
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...
3
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...
2
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>...
3
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...
4
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...
2
by: PCH | last post by:
I have 2 functions, one to serialize an object, and one to deserialize it. I can serialize just fine, the problem is when I try to deserialize it later... I get an error: {"Invalid...
0
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...
0
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...
2
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...
4
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...
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:
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
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,...
0
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...

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.