c# - Communication from WCF to WEB API -


i want consume webapi wcf service, i.e. want wcf service call web api. have searched on internet lot, forums concentrating on calling wcf web api, though need reverse of that.

is possible do?

sure can. use normal httpclient in .net application:

using (var client = new httpclient()) {     //api base address     client.baseaddress = new uri("http://localhost:9000/");     client.defaultrequestheaders.accept.clear();     client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json"));      //sending request endpoint api/products/1     httpresponsemessage response = await client.getasync("api/person/1");     if (response.issuccessstatuscode)     {         //getting result , mapping product object         person person = await response.content.readasasync<person>();     } } 

since didn't specified, above code request. can find more examples here: calling web api .net client in asp.net web api 2 (c#)


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -