Uderc programming article aggregator sites

Web Service function to return OracleDataReader

Tags:
Answers: Have 7 answers
Advertisement
My current .Net code with ODP calls a data access layer function which returns an "OracleDataReader". We would like to test an alternate approach and call a web service function instead. When I try and create the Web Service function it does not allow me to specify "OracleDataReader" as the return since it gives an error that the function cannot be serialized since it "does not implement Add(System.Object).".
Is there an Oracle.DataAccess.Client alternative? Does this mean I have to return a "DataSet" since it is the only data structure which can be serialized?
Advertisement
The best answer: this is pseudo c#
snippets of a class definition NB Note the Serializable decoration
#region ADPerson definiton
     [Serializable]
     public class ADPerson
#region ADPerson fields
private string _postCode;
          private string _deliveryOffice;
          private string _telephoneNumber;
#region ADPeople collection of ADPerson
     [Serializable]
     public class ADPeople : System.Collections.CollectionBase
          public int Add(ADPerson value)
This is in my web method
using AD = ADClasses;
#region main lookup method
          [WebMethod(Description = "Lookup in Active Directory")]
          public AD.ADPeople ADLookup(string strSearchCriteria, string strUser, string strPassword, string strDomain)
AD.ADPeople adPeople = new AD.ADPeople();
AD.ADPerson ap = new AD.ADPerson();
adPeople.Add(ap);
return adPeople;
Just make sure that your class(es) are serializable and return them from your web service. If you call the ser vice from a browser you will see your class as xml. If you call it from an app you can do something like
class c= callWebService(param);
HTH