开发者

What are WCF Proxies and what are they good for?

I have recently been educating myself about WCF and I have even written some production services using WCF. But I have never really looked too much into WCF until recen开发者_Go百科tly.

I am aware of the idea of the "proxy" design pattern. I am also aware of the use of a proxy with ASMX web services. But I am having a hard time understanding what a WCF proxy is and how it is used. I have looked thoroughly over the MSDN documentation about WCF, but I am still not grasping the big picture of the use of proxies with WCF services.


A proxy is an in-process representative of an out-of-process service. You call the proxy (which is easy), which setups up the communication channels etc. and talks to the remote service (which is hard).

See also http://msdn.microsoft.com/en-us/library/ms730144.aspx.


A WCF proxy is really just a level of abstraction. You code against the proxy (ultimately an interface which is a service contract) without needing to work with the fine grain detail of dealing with the WCF communication logic. The benefit of WCF is that you can use many types of communication with the service (http, wshttp, msmq, named pipes etc) with the same proxy.


Technically speaking Proxy is CLR Class that exposes single CLR Interface which represents the Service Contract.The proxy provides same operations as ServiceContract , but also additional methods for managing the proxy life cycle and the connection to the service

                           or

Proxy is use to Represent the ServiceContract Interface in Server from client side.By using proxy we can invoke service methods which Present in Interface which lies in Server.


Client proxy is required to consume WCF services from .NET clients. Proxy is an object in memory on the client-side that exposes the same Interface or API that the WCF service does. Your consuming code will make calls against that proxy and proxy will dispatch those calls as SOAP Messages to the WCF service.

Proxies can be code-generated by Visual Studio based on the metadata exposed by the WCF service either in WSDL or WS-MetaDataExchange endpoint(which is SOAP based).

If you want more control over service consumption then you can hand-code proxies. Like you want to encapsulate the repeating pattern of usages e.g setting up credentials etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜