Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
REST web service
Message
De
17/12/2014 09:03:03
 
 
À
17/12/2014 08:19:33
Information générale
Forum:
Internet
Catégorie:
Autre
Divers
Thread ID:
01612361
Message ID:
01612363
Vues:
41
>>Hi
>>
>>I've got some code that accesses a REST web service to get authorisation and then get a token.
>>
>>The line XDocument doc = XDocument.Load(stream);
>>
>>returns an error
>>
>>'doctype' is an unexpected token. The expected token is 'DOCTYPE'
>>
>>How can I see the contents of the response stream and why would I get that error ?
>>
>>Thanks
>>
>>
>>HttpWebResponse response = ProfileSampleApp.httpWrapper.getAccessToken(accessTokenURL);
>>string token = Utils.getElementValue("Token",response.GetResponseStream());
>>
>>public static string getElementValue(string elementName,Stream stream)
>> {
>> XDocument doc = XDocument.Load(stream);
>> return (from element in doc.Descendants(elementName)
>> select element).Single().Value;
>> }
>
>Sounds as if the incoming is using 'doctype' and the parser is insisting on the upper case version.
>
>You could use Fiddler to see what's coming in. If it is 'doctype' then maybe you could get the stream into a string, adjust the value and then use XDocument.Load() with the TextReader option ?

Bear with me Viv I'm flying a bit blind here.

I added this

public static string getElementValue(string elementName,Stream stream)
{
StreamReader reader = new StreamReader(stream);
string fileInfo = reader.ReadLine();
XDocument doc = XDocument.Load(stream);
return (from element in doc.Descendants(elementName)
select element).Single().Value;
}

and in debug fileinfo is empty. Would I expect to see a response in there ? Can I access this stream like that ?

Update I changed readline to ReadToEnd and now I can see its returning a web page which is wrong. thats some progress I guess
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform