wcf client with out proxy,4 Piller of WCF , WCF Client in asp.net without/no proxy.

I am working on applications which are based on SOA since 2.5 years, I worked on differenerent applicaitons which help to integrate two system with security and off course hight availability.
Bofore a year we had an order to shift our all applications on WCF architecture before that we worked on lagacy services with asmx extension.
I found WCF more secure and reliable as Microsoft recomend for secure channel (more detial). We have 100’s of applications which provide their functionality to integrate different system on middle ware channel . To monitor any services we have developed a asp.net application which send request and get response to check the availability of services. Our asp.net applicaiton work fine with the .asmx and also it worked perfect to get response with other domain. Our problem get starts when we shift our services to WCF architecture. In the lagacy .asmx web applicaitons we didnt find any hardle because .net class library System.NEt worked greate for us,we by using WebRequest calss send xml request to any web service (only asmx) and get response, but when we use the same for WCF service we get an exception.
I google alot and try to find the solution with my team but we didn’t get time to have an answer, but to get the soution i google the whole WCF architechture and summriesd the four main point of WCF architecture which are also workable and useable for WWF in .net application.

Tenet 1: Boundaries Are Explicit
This tenet reiterates the fact that the functionality of a WCF service is expressed using well-defined
interfaces (e.g., descriptions of each member, its parameters, and its return values). The only way
that an external caller is able to communicate with a WCF service is via the interface, and the exter-
nal caller remains blissfully unaware of the underlying implementation details.

Tenet 2: Services Are Autonomous
When speaking of services as “autonomous” entities, we are referring to the fact that a given WCF
service is (as much as possible) an island unto itself. An autonomous service should be independ-
ent with regard to version issues, deployment issues, and installation issues. To help promote this
tenet, we yet again fall back on a key aspect of interface-based programming. Once an interface is
in production, it should never be changed (or you will risk breaking existing clients). When you
need to extend the functionality of your WCF service, simply author new interfaces that model the
desired functionality.

Tenet 3: Services Communicate via Contract, Not Implementation
The third tenet is yet another byproduct of interface-based programming in that the implementa-
tion details of a WCF service (which language it was written in, how it gets its work accomplished,
etc.) are of no concern to the external caller. WCF clients interact with services solely through their
exposed public interfaces. Furthermore, if the members of a service interface expose custom com-
plex types, they need to be fully detailed as a data contract to ensure all callers can map the content
into a particular data structure.

Tenet 4: Service Compatibility Is Based on Policy
Because CLR interfaces provide strongly typed contracts for all WCF clients (and may also be used
to generate a related WSDL document based on your choice of binding), it is important to point out
that interfaces/WSDL alone is not expressive enough to detail aspects of what the service is capable
of doing. Given this, SOA allows us to define “policies” that further qualify the semantics of the serv-
ice (e.g., the expected security requirements used to talk to the service). Using these policies, we are
able to basically separate the low-level syntactic description of our service (the exposed interfaces)
from the semantic details of how they work and how they need to be invoked.

Source of these points are : pro C# 2008 and the .net 3.5 (Apress)

I found the answer in the first tenets of WCF,
“The only way that an external caller is able to communicate with a WCF service is via the interface, and the external caller remains blissfully unaware of the underlying implementation details”

Now for consuming any WCF service we need to create a channel to that service which is hosted on our target system, and as mentioned above that we need to have an interface which help us to get the funcationlity of that service though channel and by telling bindings of that service.

Now for simplcity I created two wcf serivices and hosted them to the IIS. One of the them service has GetCalulateValue method and another and GetData and then I will consume both of these methoed in aps.net application.

But we need to note something here which is that we need to capture data contracts and service contract of service which help us to communicate supports a number of properties to further qualify its intension in a separate dll.

WebService Interface

WebService Interface

as I change the name of an interface, so please dont forget to chagne the web config endpoing address tag
like mentioned below.

further detail of service

further detail of service

As above figure shows that we have to take care of namespace which we will use in our client for consuming response form service via interface.

Now Create another service, with any method which can have any functionality, we can also develop service from biztalk but point here is to take care of namespace which give us interface detail in dll, helpfull for us in consuming service.
Now I have deployed both two service on IIS. Let start making client for them. So far you may have an idea which thing is important in consuming wcf.

service configuration

service configuration

above configuration file mentioned the in which the main three things are mentioned.endpoint,binding and contracts.

Now First Create a MVC web application. In consuming WCF service we need to add two web reference (1) System.ServiceModel that define bindings and hosting type as well as basic security and transactional type. Another namspae which we need to add on our page is of Service Interface, we need to have that dll, can take it from the bin folder of service and add in the root folder of webiste. This mean that for each service we need to add a dll atleast which provide us a tunnel or path for data to consume via unique interface of service.

After adding all three dlls, (1) System.ServiceModel, (2) Dll of WCf Service one ClientInfo, (3) Dll of Wcf Web Servie 2 Calculator, Now you are ready to get a response by few lines of code mentioned below.

asp.net code

in my next blog i will show a client of BizTalk service, which is little tricky but this blog in detail may give an idea for all type of client.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s