WCF Hosts and Endpoints
<%@ ServiceHost Service="Service1" %>
//or WebServiceHost for web
var host = new ServiceHost(
//or pass new MyService() for singleton
//params or array of base addresses
//baseAddress + service name = full url.
//If no base address, can use full address here.
- You can add several base addresses (ServiceHost ctor has a params argument).
- For non-HTTP IIS, make sure the appropriate service is running and use IIS 7's appcmd: %windir%\system32\inetsrv\appcmd.exe set app "x/service" /enabledProtocols:http,net.tcp
- For MSMQ, create a queue named MyServiceHost/service.svc : the endpoint has address="net.msmq://localhost/private/MyServiceHost/service.svc" binding="netMsmqBinding"
- In a hosted environment (IIS, WAS), a ServiceHost is configured automatically. To customize, replace the ServiceHostFactory to return your own dynamically configured ServiceHost: <%@ ServiceHost Factory="DerivedFactory"
- You can create an IIS service without an svc file. In web.config, add system.serviceModel/serviceHostingEnvironment/serviceActivations.
- You can have multiple endpoints for one host (either different bindings to the same contract or different contracts with the same binding - don't new NetTcpBinding() in each )
- Routing- in .net 4 use WCF routing. For .net 3:
- ClientViaBehavior is an intermediate route- the client uses the clientVia physical address, but the "To:" address is the logical address.
- WS-Addressing (routing): var addressHeader = AddressHeader.CreateAddressHeader("name", "http://ns.org", valueobject);
- Metadata support ?wsdl : <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
- HTTP GET: Service behavior: <serviceMetadata httpGetEnabled="true" />