Tuesday, January 13, 2009

Invoking WCF Service without adding a Service Reference.

 

Basically via VS.NET IDE we reference the WCF service as shown below. doing this way we need to update the service Reference whenever WCF service Operation or Data Contracts changes.

image

 

 

 

 

 

 

 

Here is the way we can Invoke WCF service with out Adding a Service Reference.

 

image

 

Thanks

SreenivasaRagavan.

9 comments:

savitha said...

Without adding service reference how can you get the interface IFortune?Can you explain

Sreeni.NET said...

Hi Savitha,
IFortune is the ServiceContract.
just Add all SeviceContract Interfaces to your Client Project that is all.
Thanks
Ragavan

Viswanathan said...
This comment has been removed by the author.
Viswanathan said...

Hi,
Is there a way we can invoke WCF even without including the Service Contract Interface in our project? This is possible for Web Services using System.Web.Services.ServiceDescription object and System.Web.Services.ServiceDescriptionImporter instances.
I just cant get through to invoke WCF similarly.

Sreeni.NET said...

Hi Viswanathan,
I think when you use this System.Web.Services.ServiceDescription you are basically creating proxy dynamically and invoking .

Viswanathan said...

yes. But since the architecture of WCF is different from web service, like we need contracts, end points, etc, we cannot use System.Web.Services.Description.ServiceDescription class. This causes exceptions especially when it is wsHTTPBinding. I came across Vipul Modi's blog with source code for a dynamic WCF client - http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx.

But that is too sophisticated. I am just expecting a small method as a one that can be achieved with ServiceDescription class.

Fawad Tariq said...

This is very nice and informative blog thanks for sharing this informationareService Contractsfully insured to provide your belongings the extra cushion that they might need during the transit and giving you the peace of mind that your valuable possessions are in good hands.

Ravinder Singh, PMP said...

"just Add all SeviceContract Interfaces to your Client Project that is all."

Don't you think if there is any change in ServiceContract Interfaces then we need to our client as well? If yes, so how it is different from adding service reference?

aparna john said...

Hi,Planning websites is pretty much like designing stage sets, it must look great, but under the surface it has to work with Web Design Cochin so that the search sites and web surfers can find your website.Thanks....