WCF Addressing In Depth Note
来源:互联网 发布:4g语音与数据 编辑:程序博客网 时间:2024/04/28 18:36
WCF Addressing In Depth
http://msdn.microsoft.com/en-us/magazine/cc163412.aspx
-Addressing Fundamentals
-Relative URIs (base address)
-Absolute URIs
-IIS AddressingConsiderations
-IIS control the base address
-Not only does IIS control the base address,it forces all of your endpoints to actually use the same base address(unlikeself-hosting). This means that if you do specify an absolute address for aparticular endpoint, it must start with the base address corresponding to thevirtual directory or you’ll get an exception.
-Suppose you have a file named calc.svc and youplace it in a virtual directory that corresponds tohttp://localhost:8080/calcservice. The base address for this service will be http://localhost:8080/calcservice/calc.svc
-If u have arelative address="secure" then absoluteaddress="http://localhost:8080/calcservice/calc.svc/secure"
-If u have arelative address="mex" then absoluteaddress="http://localhost:8080/calcservice/calc.svc/mex"
-Multiple Endpointsand Unique Addresses
-When exposing multiple endpoints withdifferent bindings,each endpoint address must be unique. This is because each endpointrequires a different transport listener and channel stack.
-e.g.:
<services>
<servicename=”CalculatorService”>
<endpointaddress=”http://localhost:8080/calcservice”
binding=”basicHttpBinding”
contract=”ISimpleMath”/>
<endpointaddress=”http://localhost:8080/calcservice/secure”
binding=”wsHttpBinding”
contract=”ISimpleMath”/>
-Multiple endpoints share the same binding, youcan use the same addressacross those endpoints.
-e.g.:
<services>
<servicename=”CalculatorService”>
<endpointaddress=”http://localhost:8080/calcservice”
binding=”wsHttpBinding”
contract=”ISimpleMath”/>
<endpointaddress=”http://localhost:8080/calcservice”
binding=”wsHttpBinding”
contract=”IScientific”/>
-Logical vs. PhysicalAddresses
-When defining an endpoint for a WCF service, the "address" attribute (in case of defining it in a configuration file) is the logical address.The logical address corrsponds to the "To" header defined in WS-Addressing. Default WCF uses the same address as the physical address, butthe physical address can be set individually in the "listenUri" attribute. The physical address corrsponds to the "Via" header defined in WS-Addressing. The logical address is important when WCF should dispatch the incoming message, because default it requires an exact match between the "To" header in the message and the "address" attribute.
-Windows Communication Foundation refers to thelogical address as "Address" or "Endpoint Address" and the physical address as "ListenUri".
-When you specify endpoint addresses like I’vedone thus far, you’re actually supplying the logical address. However, thelogical address is also used as the physical address unless otherwisespecified.
-Physical Address can accomplish in configurationusing thelistenUriattribute
<services>
<servicename=”CalculatorService”>
<endpointaddress=”urn:calcservice:simplemath”
listenUri=”http://localhost:8080/calcservice”
binding=”wsHttpBinding”
contract=”ISimpleMath”/>
<endpointaddress=”urn:calcservice:scientific”
listenUri=”http://localhost:8080/calcservice”
binding=”wsHttpBinding”
contract=”IScientific”/>
-Addressing Headers
-In order to accommodate even moresophisticated routing anddispatching logic, you may want to annotate SOAP messages withcustom addressing headers.
-e.g.:
-<services>
<servicename=”CalculatorService”
behaviorConfiguration=”metadata”>
<host>
<baseAddresses>
<addbaseAddress=”http://localhost:8080/calcservice”/>
</baseAddresses>
</host>
<endpointbinding=”wsHttpBinding” contract=”ISimpleMath”>
<headers>
<basicxmlns=”http://example.org/level”/>
</headers>
</endpoint>
<endpointbinding=”wsHttpBinding” contract=”IScientific”>
<headers>
<premiumxmlns=”http://example.org/level”/>
</headers>
</endpoint>
</service>
-Message Filters
-Each endpoint actually has two filters associatedwith it—anaddress filter and a contract filter. The address filter determinesif the incoming message matches the endpoint’s "To" address and any required address headers, while the contract filter determines whether it matches the endpoint’s contract. Both filters are used by the dispatcher todetermine the destination endpoint.
-An easy way to change the message filter used bya service is through the AddressFilterMode property of [ServiceBehavior].AddressFilterMode comes with three values:Any, Exact, and Prefix.
e.g:
-[ServiceBehavior(AddressFilterMode=AddressFilterMode.Prefix)]
public classCalculatorService : ISimpleMath, IScientific
{
-Windows Communication Foundation does come withanXPathMessageFilter, which allows you to evaluate arbitrary XPath expressionsagainst incoming messages during the matching process, single-handedly coveringcontent-driven scenarios.
-Host NameComparisons
-Issue: if you want to configure the endpoint tolisten for all host names bound to a particular machine (localhost, contoso,www.contoso.com, and so on)
-You can further control this via theHostNameComparisonMode, which is made available on most bindings as a property.HostNameComparisonMode comes with three settings: StrongWildcard (the default),Exact, and WeakWildcard.
- WCF Addressing In Depth Note
- New in WCF 4.0 Note & Filters for Message Logging Note
- Note on depth texture
- Depth upsampling note
- WCF + vs2005 Video Note
- Learning WCF - Security Note
- WCF Tracing Note
- addressing manner in structured data accessing
- Extended Physical Addressing in Protected Mode
- WCF 4 Step By Step Chapter 4 Note (Transport and Message Security + Authentication in Organization)
- WCF 4 Step By Step Chapter 5 Note (Authentication in Internet)
- 6.087 Practical Programming in C, lec5: Pointers and memory addressing
- 【论文阅读】Addressing the RareWord Problem in NeuralMachine Translation
- Network+ 2005 In Depth
- read 'Database In Depth'
- Containers in depth笔记
- Controller in depth
- [CSharp In Depth]迭代器
- windows系统实现组播
- ArrayList,HashSet,HashCode,Properties一起理解!
- Apache http server 安装
- 《STL源码剖析》-- stl_vector.h
- 数据库查询1
- WCF Addressing In Depth Note
- 数据库查询2
- Exercises 4-12
- Floyd 算法深究
- 电子游戏能改变人的大脑
- vs中,在ASPX文件下面有智能提示,但是为什么新建一个类,却没了智能提示
- Youp(orn)网站架构
- Android Service
- 互联网技术网站