Discover WCF hosted by Windows Service
In the solution, 4 projects : Business, the WCFService and开发者_如何学JAVA the WCFServiceHost (a windows service) and a client
When I work in the solution, no problem, I can discover and create the proxy in the client.
When I install the host service, I start it but impossible to discover and create the proxy from visual studio with this : net.tcp://localhost:9100/MyApplicationWcf
Any idea ?
Thanks,
update #1
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="MyApplicationWcf.MyClassWcf">
<endpoint address="net.tcp://localhost:9100/MyClassWcf"
binding="netTcpBinding"
bindingConfiguration=""
name="MyClassWcf_Tcp"
contract="MyApplicationWcf.MyClassWcf" />
<endpoint name="mexHttpBinding"
contract="IMetadataExchange"
binding="mexHttpBinding"
address="mex" />
</service>
</services>
</system.serviceModel>
</configuration>
If you want to discover the service over net.tcp, you will need to define a MEX endpoint (metadata exchange) that uses the mexTcpBinding.
<behaviors>
<serviceBehaviors>
<behavior name="MexBehavior" >
<serviceMetadata/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="mexBinding" portSharingEnabled="true">
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="YourServiceImpl"
behaviorConfiguration="MexBehavior">
<host>
<baseAddresses>
<add baseAddress ="net.tcp://localhost:9100/MyApplicationWcf/"/>
</baseAddresses>
</host>
<endpoint address=""
binding="netTcpBinding"
contract="IYourServiceContract" />
<endpoint address="mex"
binding="mexTcpBinding" bindingConfiguration="mexBinding"
contract="IMetadataExchange" />
</service>
</services>
Do you have that??
Check out: How to: Publish Metadata for a Service Using a Configuration File for more information.
精彩评论