REST samples

I downloaded the BizTalk SDK a while back and the new (Orcas beta 2) samples on MSDN earlier today. I am interested in whether i can pass an object as part of a GET query and have this execute.

The samples are very basic and simply show passing a scalar "id" parameter for GET queries. I'd like my interface to be (for example) "Customer customer" rather than "string id" for GET queries.

However, i'd like consumers (by typing the query directly into the browser address bar) to be able to query against this interface.

Is this possible? In looking briefly, i can understand how the POST mapping works, but i'd like to see some examples on what can be done with GET. I simply want to map the input query to a Customer object and have the WCF service accept this.

Anyone got some articles/samples to point me at that specifically looks at this?

Regards,

Steven

http://livz.org

[1026 byte] By [weblivz] at [2008-1-8]
# 1

In Beta2, you should be able to use the [StringConverter] attribute on your type to convert it to/from a URI template variable.

Thanks

Vish

T.R.Vishwanath-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 2
I guess Vish means TypeConverterAttribute.

ChristianWeyer at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 3

What does it mean to "map an input query into a customer object?" It sounds like you want a place to plug in your ORM and/or Data Access layer...usually, that type of work is done inside the service implementation...

-steve

SteveMaine--MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 4

Hi Steve - to *get* to that entity object which is part of your ORM, you need to map the name-value pairs in the GET request to construct an actual object instance.... much as i suspect happens in the WCF POST support.

So consider the case where i want to query on a surname of a person and a List of locations - so my interface may look as follows:

public Person Find(string surname, List<Location> locations);

I'm interested in whether it is possible to do this as an HTTP GET - i can imagine ways in which it could be supported, but haven't seen any examples on whether it is or not.

I can easily make this accept primitive types only, but it would be nicer and more consistent if i could just expose List<Locations> and this was supported in such a way i could ever type it into a web browser and get a result.

Regards,

Steven

http://livz.org

weblivz at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 5

Steve - by chance, I see you read (and commented on) this a while back.

http://integralpath.blogs.com/thinkingoutloud/2007/05/index.html

This is what i mean by "mapping" - xpath would be quite powerful too.

steven

http://livz.org

weblivz at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 6

Steve,

Currently a interface like the one that you mentioned (public Person Find(string surname, List<Locations> locations) is not supported with an HTTP GET. An HTTP GET request may come from a web browser, and all parameters that are sent to the operation need to be specified in the URL. There isn't any set way to represent a list of locations in the URL.

Thanks,

Michael Green [MSFT]

MichaelGreen-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 7

Hi Michael - thanks for this. I think rather than "there is no way", i'd say it just isn't supported.

I can imagine for example the ability to set a URITemplate to almost anything that maps locations with a name as follows:

http://domain.com/service/surname=livingstone/locations/1,glasgow/2,Edinburgh and so on....

That is just one way i can imagine and in fact is how i had written my own custom URL to Object parser prior to the great work from you guys in 3.5. As is pointed out in the link above, we could easily use XPath to relate these items - i think this is how SQLXML templates did it.

I only ask as when i define my contracts, i define them as entities rather than scalar values - although from a GET perspecitive i can see this is tricker - but anything i can may in RegEx i'd imagine can come through a GET request and mapped to an object.

But thanks - at least i know i'm not missing anything and can re-define my interfaces accordingly for REST and for SOAP.

steven

http://livz.org

weblivz at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified