c# - How to read the StreamReader response from Client? -


i new rest webservices. there existing rest service need consume in c# console application. getting xml response in following line.

readstream.readline(); 

how can make use of rest response in client?

utility

  public void searchcontactdetailsasync(models.addressbookrequest addressbookdatarequest)     {         uribuilder builder = new uribuilder(url);         restclient.dopost(builder.uri, serializer.serializexml(addressbookdatarequest.contactssearchcriteria), searchcontactsuccess, searchcontactfailed, addressbookdatarequest.headerparams);     }      private void searchcontactsuccess(httpwebresponse response)     {         //call base service method - inspect response , publish event         handleservicesearchsuccess<contactdetailspreview[]>(searchcontactdetailscompleted, "contactdetailspreviews", response);         stream receivestream = response.getresponsestream();         encoding encode = system.text.encoding.utf8;          streamreader readstream = new streamreader(receivestream, encode);         readstream.readline();      } 

console app

    public void mymethod()     {         autorestevent = new autoresetevent(false);         services = new communicationsvcs();         services.searchcontactdetailscompleted += new eventhandler<restclientutility.eventarg.serviceresponseeventargs<restclientutility.models.contactdetailspreview[]>>(services_searchcontactdetailscompleted);          //call operation         addressbookrequest req = new addressbookrequest         {             contactssearchcriteria = new contactssearchcriteria             {                 searchuserid = "ss23ed"              },             headerparams = new restclientutility.requests.httpheaderparms             {                 userid = "ss23ed",                 userprincipalname = " ss23ed@hotmail.com",                 contenttype = "application/xml"             }         };         services.searchcontactdetailsasync(req);         autorestevent.waitone();      } 

references

  1. xml deserialization generic method

.net's xmldocument class has load() method accepts stream

as see it, need provide stream it

 xmldocument doc = xmldocument.load( readstream ); 

i can't see if it's static method , have no environment test right here, maybe need create instance of xmldocument first , run load() method (if it's not static)


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -