wcf - ReadAsDataContract exception while reading namespace -


I'm trying to use Twitter's Rest API using the WCF Rest Starter Kit. I am using the same object in the data content described in the article. [Collection Data Contract (name = " Status list, "Item name =" status ")) Public category status list: list & lt; condition & gt; {} public class user {public string id; public string name; public string screen_name;} public class status {public String id ; Public string text; public user user;}

I am reading XML content using the RedAs Data Contract () method.

  HTTP client http = New HTTP client ("http://twitter.com/costs/"); Http.TransportSettings.Credentials = New network credentials ("{user name}", "{password}"); HttpResponseMessage resp = http.Get (" Friends_timeline.xml "); resp.EnsureStatusIsSuccessful (); Status list sList = resp.Content.ReadAsDataContract & lt; positioning & gt; ();  

I get the argument that I have not defined the following namespace at all

error in line 1 position 24 Expecting 'Elements' from Namesh place' Element 'was inaugurated with' '... names' situations, namespace' '.

Please help. Thank you.

Just do not do that. If you try to use dataconnects and operation contracts to access non-YCF services, then you are in the world of pain.

OK, so I think an alternative was left without you being high and dry, so try:

  var response = client.get ("http : //twitter.com/statuses/friends_timeline.xml "); Var position = response. material. Readxelment (); Var in position = position in the st. Select the Elements ("Status") New Status {id = st.Element ("id"). Value, text = st.Element ("text"). Value, user = (value of us, name = us.Element ("name"). Value, screen_name = us.Element ("screen_name"). Value ("user").}). FirstOrDefault ()}; Var position = position Tollist (); Using the Linux to create an object from an XML document, you can avoid the magic of the serializer and completely control the names and datatages of your client side objects. It would be really easy to wrap this as a new HTTP content extension method so that you can do just that:  
  var status = response the seminar. ReadSteaver Stats ();  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -