Salakhetdinov Shamil
mcp2004 at mail.ru
Thu May 3 08:10:02 CDT 2012
Hi Gustav at all -- Just wanted to finish my first try of oData web services consumption on positive note and applied KISS-principle by writing a tiny oData client app - and I have got some progress here in consuming sample oData (?) service from Chris Sells article: http://services.odata.org/Northwind/Northwind.svc You can do the same - just: 1. Create VS2010 console application project - ConsoleApplication1 2. Add Service Reference to http://services.odata.org/Northwind/Northwind.svc and call it TestService 3. Copy & paste, compile, build, and run code from P.S. of this message - and you'll get the following test output: 5. Buchanan Steven - Sales Manager 1. Davolio Nancy - Sales Representative 9. Dodsworth Anne - Sales Representative 7. King Robert - Sales Representative 3. Leverling Janet - Sales Representative 4. Peacock Margaret - Sales Representative 6. Suyama Michael - Sales Representative Easy? Yes, it's. .NET 'magic' makes all the dirty work for you to parse web query ATOM result of http://services.odata.org/Northwind/Northwind.svc/Employees (try it in a web browser) into the above test output. Question to Francisco: does ObjectiveC have similar high level ATOM feeds consuming libraries and tools to generate strongly typed client APIs? (I should have I guess...) Thank you. -- Shamil P.S. using System; using System.Linq; using System.Data.Services.Client; namespace ConsoleApplication1 { public class DataModelProxy : DataServiceContext { public DataModelProxy(Uri serviceRoot) : base(serviceRoot) {} public IQueryable<dynamic> EmployeesList { get { return CreateQuery<dynamic>("Employees"); } } public IQueryable<ConsoleApplication1.TestService.Employee> StronglyTypedEmployeesList { get { return CreateQuery<ConsoleApplication1.TestService.Employee>("Employees"); } } } class Program { static void Main(string[] args) { var proxy = new DataModelProxy(new Uri(@"http://services.odata.org/Northwind/Northwind.svc/")); //var employees = from e in proxy.EmployeesList select e; var employees = from e in proxy.StronglyTypedEmployeesList where e.Title.StartsWith("Sales") orderby e.LastName select e; foreach (var e in employees) { Console.WriteLine("{0}. {1} {2} - {3}", e.EmployeeID, e.LastName, e.FirstName, e.Title); } } } } Thu, 03 May 2012 08:31:02 +0200 от "Gustav Brock" <Gustav at cactus.dk>: > Hi Shamil > > Thanks! That looks like a good article - and using Northwind as example data, I noticed. > I will have a closer look in the weekend. > > /gustav > > > >>> Salakhetdinov Shamil <mcp2004 at mail.ru> 03-05-2012 00:03 >>> > Hi Francisco and Gustav -- > > Here is a link, which seems to have good information how to make and how to communicate with oData (web) services: > > "Open Data Protocol by Example" by Chris Sells: > http://msdn.microsoft.com/en-us/library/ff478141.aspx > > Thank you. > > -- Shamil > > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > >