Click here to Skip to main content
15,922,145 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my webmethod., i am doing this
C#
[WEBMETHOD]
 XDocument xd = XDocument.Load(@"D:\satish1\na.xml");
            var query = from p in xd.Descendants("item")
                        select new
                        {
                            name = p.Element("title").Value,
                            des = p.Element("description").Value
                        };
            return query.ToString();


when I want to consume this method , i am writing this

C#
WpfApplication1.ServiceReference1.Service1SoapClient proxy = new WpfApplication1.ServiceReference1.Service1SoapClient();
            DataSet ds = proxy.getdetails();
          
            ds.WriteXml(@"D:\satish1\sb.xml", XmlWriteMode.WriteSchema);

I am not able to use ds.write xml method ,and save the xml output in my system. It is saying cannot convert system.data.dataset,
In my webmethod iam returning strings can i return xml there, also in my proxy call can I convert that string to system.data.dataset.

please tell me in some code
Posted
Updated 19-Dec-11 17:56pm
v2
Comments
Sergey Alexandrovich Kryukov 20-Dec-11 0:34am    
In what line "it is saying"?
--SA
satishmachineni 20-Dec-11 0:42am    
when i conume the webmethod ,and write
ds=proxy.getdetails();
it is saying that thing.
what i want to do actually is
write the thing likr that and stote it using
ds.writexml(path,xmlwritemode.writeschema)

1 solution

The question is a result of totally broken logic. Suppose a compiler tells you "cannot convert type A into type B". It is very illogical to use this fact to ask a question "OK, and how can I convert A into B?". Just the opposite, it's most likely the indication that using the type A where type B is expected simply makes no sense.

Take a question about "conversion" of a string into a DataSet. It makes no sense. Generally string is a string, it is not "converted" into anything except may be another object which is a different technical representation of the idea of string, such as null-terminated string or something else.

Even though in same cases a string can represent a Dataset, but there is no such operation as "conversion". It can be serialization of some object or object graph into a string in some format, for example, based on XML or JSON, which deserialization used to re-create an object or an object graph equivalent to original one. It could be parsing of such format. Whatever it is, it cannot be called "conversion".

In your code sample, your DataSet probably has no current schema you are trying to right. In this case you cannot right anything, according to http://msdn.microsoft.com/en-us/library/system.data.xmlwritemode.aspx[^].

It is not clear to me where your exception comes from, as you did not clearly indicate what did you face with: an exception or compilation error, what was exact message, line of code and other relevant information. You should always provide such information in a comprehensive way when asking questions.

—SA
 
Share this answer
 
Comments
satishmachineni 20-Dec-11 0:55am    
ok, i am totally new to coding , iam just trying to understand, any way thanks
Sergey Alexandrovich Kryukov 20-Dec-11 0:58am    
You are welcome. Trying to understand is good. This way, sooner or later you will get a good grip on things.
Good luck, call again.
--SA
satishmachineni 20-Dec-11 1:04am    
one more question ,i dont know what , in my first lines of code
var query = from p in xd.Descendants("item")
select new
{
name = p.Element("title").Value,
des = p.Element("description").Value
};
return query.ToString();
if i dont keep here to string , it is sayingcannot implicitly convert to system .collections.ienumerable to string,if i use here to string ok build is succeded,i dont want to return strings, can i return anything otherthan strings there.sorry if dis not makessense,for us webservice was taught one day ,and were told to implement..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900