WCF Part 4 : Make your service visible through metadata
2012-06-16 20:25
309 查看
Forthiswedon'thavetocreateanycode,justconfigurationagain.OpentheServiceConfigurationEditoragainonourapp.config.Openthefolder"Advanced",then"ServiceBehaviors"andchoosetoaddanewservicebehavior.We'llchangethenameNewBehaviortoHelloServiceBehavior.NowclicktheAddbuttonandselectthe'ServiceMetadata'option.
Nowwe'llconfigureournewbehaviorinandendpoint.Selectyourserviceagaininthetree.Thisissomethingyou'llprobablyforgetalotinthefuture,butyou'llhavetobindthejustconfiguredbehaviortoyourservice.YoushouldbeabletoselectitfromthelistintheBehaviorConfigurationpropertyonyourservice.
Nowlet'sactuallyaddourMEXendpoint.Selectthe"Endpoints"folderunderourserviceandright-clickit,thenchoosetoaddanewendpoint.Settheaddressto
<?xmlversion="1.0"encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behaviorname="HelloServiceBehavior">
<serviceMetadata/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<servicebehaviorConfiguration="HelloServiceBehavior"name="Classa.Wcf.Samples.Hello">
<endpointaddress="http://localhost:8080/HelloService/"binding="basicHttpBinding"
bindingConfiguration=""contract="Classa.Wcf.Samples.IHello"/>
<endpointaddress="http://localhost:8080/HelloService/MEX/"binding="mexHttpBinding"bindingConfiguration=""
contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
</configuration>RunyourservicewithF5.You'llnoticenodifference,butnowyoucancreateaproxywiththeserviceutil.OpentheVisualStudioCommandPrompt(inyourstartmenuunderVisualStudio2005/VisualStudioTools)andexecutethefollowingcommand:
svcutil.exe/o:client.cs/config:app.config
Ifyou'reinterested,takealookatthegeneratedfiles.Especiallythegeneratedapp.config,whichshouldcontainanABCreferencetoyourservice.
相关文章推荐
- [译]WCF Part 4 : Make your service visible through metadata
- 译释Dozen ways to find bugs(9)——Make it part of your build process
- Calling a WCF service from your Silverlight application
- Christian Weyer: Smells like service spirit : Exposing metadata from WCF services - Ref 3
- 【转】ASP.NET MVC 3 Service Location, Part 7: Model Metadata
- How to: Publish Metadata for a WCF Service.(What is the Metadata Exchange Endpoint purpose.)
- 配置AJAX Enabled WCF在hosting时: Showing the serviceMetadata in an ASP.NET AJAX Service
- What if you encounter a problem when consume your WCF service ? How to Diagnostic it ?
- 使用wcf服务捕捉到“POST http://yourIP/WCFService.svc 405 (Method Not Allowed) ”错误!
- 通过MEF来创建具有扩展能力的WCF Creating WCF Service Extensibility through MEF (Managed Extensibility Framework)
- HTTP could not register URL http://+:****/WCFService/. Your process does not have access rights to this namespace
- How to get MetaData on client side in WCF?如何在客户端获取WCF service的元数据
- Service Discovery in WCF 4.0 – Part 1 z
- Service Discovery in WCF 4.0 – Part 2 z
- How to make a simplest WCF service work on Win7 with VS2010
- How to make changes to wcf service without breaking clients
- WCF Part 3 : Hosting the service
- WCF Part 5 : Consuming the service
- Make your owner PE Protector Part 1: Your first EXE Protector
- Why "using" may play tricks on your WCF service host