philprice Posted March 27, 2003 Posted March 27, 2003 The topic says it all, i want my web method to return a class, does it need to implient serializable? Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
maxter Posted March 27, 2003 Posted March 27, 2003 needn't In my opinion... you needn't implement serializable class to develop a WebService. But is rare, that you want return a class. Normaly, in WebServices the results returned are access to ejecute functions, you can offer at user the functions or subs of the class. no.... I don't know, jejeje im beginner developer.... Bye. Quote
*Gurus* Derek Stone Posted March 27, 2003 *Gurus* Posted March 27, 2003 The class needs to be serializable to XML, most definately. Since SOAP, the underlying protocol of web services, utilizes XML as its structural markup language all data that is transferred has to be XML, no exceptions. Your class will be serialized to XML before it's sent, and back to the class once it's been received. Quote Posting Guidelines
philprice Posted March 27, 2003 Author Posted March 27, 2003 its only a data class, no methods. So derek what do i need to flag to make a class serializable to xml? The whole point of my current project is to take all processing off a pocketpc device, so it just recives data and .net handles all the parsing etc, not my own code. Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
wyrd Posted March 27, 2003 Posted March 27, 2003 Just add the serializable attribute before the keyword class.. <Serializable()> class SomeClass { // .... } Quote Gamer extraordinaire. Programmer wannabe.
*Gurus* Derek Stone Posted March 28, 2003 *Gurus* Posted March 28, 2003 Keep in mind that there are numerous attributes under the System.Xml.Serialization namespace that will allow you to better format the serialized XML that is produced from a custom class. Examples of these attributes include XmlElementAttribute, XmlAttributeAttribute and XmlTextAttribute, which define class members as elements, attributes and text, respectively. Quote Posting Guidelines
philprice Posted March 28, 2003 Author Posted March 28, 2003 okay i'll look at msdn for that stuff derek, otherwise got any interesting examples links for it? Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
*Gurus* Derek Stone Posted March 28, 2003 *Gurus* Posted March 28, 2003 While I do have a plethora of information available on the topic, so does Google, so have a gander... *hint* *hint* *nudge* *nudge* ;) Quote Posting Guidelines
maxter Posted March 28, 2003 Posted March 28, 2003 I'm confused... Well, data class, what like is it???? I think you needn't serialize your data class because Web Services .NET convert automaticaly in XML document. OK? You only must construct one function that returned a DataSet, and Web Service will converted to .XML document your DataSet automaticaly, doesn't? <webmethod()> public function GetAllDatas() as DataSet . . . return MyDataSet end function Perhaps, you want construct your own XML document. Then yes, you need serialize your data to your own document. At the end, if I was you, I serialize to XML if you need a particular XML document. And don't know, I'm so beginner......excuse me if it I'm saying, is stupid. Answer me and let me learn much. Bye. Quote
maxter Posted March 28, 2003 Posted March 28, 2003 NOW, I'M SURE. See... DATASETS is the key to 'serialize' DATA to XML. The DataSet class has several methods for reading and writing data as XML. For it, follow this steps: 1. Obtain data from your container or database. 2. Pass it to a DataSet. 3. Invoke to writeXML method of dataset class. See this example 'Saving a DataSet to a file as XML' 'Before you must populate DataSet . . . ' Save dataSet as XML. ds.WriteXml("mydataXML.xml") Its all. Also you can overload WriteXML method. To read data and import it again to a DataSet Dim ds As New DataSet( ) ds.ReadXml("mydataXML.xml") ALSO!! You can work as before with your own schema. Look at, you have to your use GetXml and GetXmlSchema methods to obtain the schema wich your DataSet work. And WriteXml and WriteXmlSchema methods to configure DataSet with your own schema. Quote
*Gurus* Derek Stone Posted March 28, 2003 *Gurus* Posted March 28, 2003 The DataSet object is serializable, yes, but that wasn't his question. The custom class that he wishes to return has to be serializable, or the SOAP can't handle it. Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.