找到你要的答案

Q:Web Service c# WebMethod return type

Q:Web服务C # WebMethod的返回类型

I am currently learning Web Services and I am wondering what return type I should use in my Web Methods.

I am trying to do an exercise (in c#) on web services that implies simulating a library. In my client, I am supposed to use the web service without having access to the classes. At least, that's what I think.

For exemple, I am supposed to receive the information about a book (title, isbn, etc...) without having access to the class that describes books.

When a web method returns a book, I understand that the book is serialized and sent to the client who is requesting it. In my c# client, I'm guessing that if I receive a Book, it means I have access to the class that describes a Book.

I think I am supposed to use a string to communicate with my client, since the client does not have access to the classes. (like this web service : http://www.webservicex.net/globalweather.asmx?WSDL which returns a string that contains XML, and then the client can use XMLDocument to parse XML and do whatever he wants with the data he received)

I have 2 questions: Is this solution the best way to use web services? (using a string containing XML to communicate with clients which don't have access to the classes). If so, do I need to convert manually the object into an XMLDocument and then convert the xml to a string and then send this string, or... am I wrong and there is a better way to achieve what I want ?

我目前正在学习web服务,我想知道我的web方法应该使用什么返回类型。

我想做一个练习(C #)Web服务意味着模拟图书馆。在我的客户机中,我应该使用web服务而不需要访问类。至少,这就是我的想法。

例如,我应该收到一本书的信息(书名,书号,等)而不必访问的类的描述书。

当一个Web方法返回的一本书,我明白了,这本书被序列化并发送到客户端,是谁要求它。我的C #客户端,我猜,如果我收到一本书,这意味着我可以访问的类,介绍一本书。

我认为我应该使用一个字符串与我的客户机进行通信,因为客户端无法访问类。(这样的Web服务:http://www.webservicex.net/globalweather.asmx?WSDL返回一个字符串包含XML,然后客户端可以使用XML文档解析XML和做他想做的事,他收到的数据)

I have 2 questions: Is this solution the best way to use web services? (using a string containing XML to communicate with clients which don't have access to the classes). If so, do I need to convert manually the object into an XMLDocument and then convert the xml to a string and then send this string, or... am I wrong and there is a better way to achieve what I want ?

c#  xml  web-services  asmx