I am still trying to from a webservuce I have the following code crafted, but for some reason when it comes to the return value its null even though when i debug the xml string value it is indead there.
public XmlTextReader readXML(string postcode, string response, string accessCode)
{
WebRequest wrURL;
Stream objStream;
string strURL;
string url = "http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode=" + postcode + "&response=" + response + "&key=" + accessCode;
wrURL = WebRequest.Create(url);
string xml = new WebClient().DownloadString(url);
objStream = wrURL.GetResponse().GetResponseStream();
StreamReader objSReader = new StreamReader(objStream);
strURL = objSReader.ReadToEnd().ToString(); #####but here it has the xml data ?####
XmlTextReader reader = new XmlTextReader(new StringReader(strURL));
return reader;#######here its empty ????#####
}
Edit
I am still not getting a response here but yet when i view it in the actual browser from the url produced within the code it displays the following
<CraftyResponse><address_data_formatted><delivery_point><organisation_name>THE BAKERY</organisation_name><department_name/><line_1>1 HIGH STREET</line_1><line_2>CRAFTY VALLEY</line_2><udprn>12345678</udprn></delivery_point><delivery_point><organisation_name>FILMS R US</organisation_name><department_name/><line_1>3 HIGH STREET</line_1><line_2>CRAFTY VALLEY</line_2><udprn>12345679</udprn></delivery_point><delivery_point><organisation_name>FAMILY BUTCHER</organisation_name><department_name/><line_1>7 HIGH STREET</line_1><line_2>CRAFTY VALLEY</line_2><udprn>12345680</udprn></delivery_point><delivery_point><organisation_name/><department_name/><line_1>BIG HOUSE, HIGH STREET</line_1><line_2>CRAFTY VALLEY</line_2><udprn>12345681</udprn></delivery_point><delivery_point><organisation_name/><department_name/><line_1>LITTLE COTTAGE</line_1><line_2>17 HIGH STREET, CRAFTY VALLEY</line_2><udprn>12345682</udprn></delivery_point><delivery_point_count>5</delivery_point_count><town>BIG CITY</town><postal_county>POSTAL COUNTY</postal_county><traditional_county>TRADITIONAL COUNTY</traditional_county><postcode>AA1 1AA</postcode></address_data_formatted></CraftyResponse>
I tried method 2 mentioned below but stil no luck
public XmlTextReader readXML(string postcode, string response, string accessCode)
{
string url = $"http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode={postcode}&response={response}&key={accessCode}";
using (Stream objStream = WebRequest.Create(url)?.GetResponse().GetResponseStream())
{
return new XmlTextReader(new StringReader(new StreamReader(objStream)?.ReadToEnd()));
}//Dispose the Stream
}
Animated gif to show debuging