What's the difference between the following two cases:
Configuration 1:
<service name="WcfService1.Service1" behaviorConfiguration="MyServiceTypeBehaviors">
<host>
<baseAddresses>
<add baseAddress="net.tcp://127.0.0.1:808/" />
</baseAddresses>
</host>
<endpoint address="service"
binding="netTcpBinding"
bindingConfiguration="MainBinding"
bindingName="MainBinding"
name="DefaultEndpoint"
contract="WcfService1.IService1" />
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
</service>
Configuration 2:
<service name="WcfService1.Service1" behaviorConfiguration="MyServiceTypeBehaviors">
<host>
<baseAddresses>
<add baseAddress="net.tcp://127.0.0.1:808/service" />
</baseAddresses>
</host>
<endpoint address="net.tcp://127.0.0.1:808/service"
binding="netTcpBinding"
bindingConfiguration="MainBinding"
bindingName="MainBinding"
name="DefaultEndpoint"
contract="WcfService1.IService1" />
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
</service>
What I understand is In either case base address + endpoint address resolves to same absolute address
But why I get the error on Configuration 2 : "No end point is listening at net.tcp://127.0.0.1:808/
but Configuration 1 runs the service without any errors!!!
Edit 1:
Working Config:
<host>
<baseAddresses>
<add baseAddress="net.tcp://127.0.0.1:808/" />
</baseAddresses>
</host>
<endpoint address="service"
binding="netTcpBinding"
bindingConfiguration="MainBinding"
bindingName="MainBinding"
name="DefaultEndpoint"
contract="WcfService1.IService1" />
Non working Config:
<host>
<!--
<baseAddresses>
<add baseAddress="" />
</baseAddresses>
-->
</host>
<endpoint address="net.tcp://127.0.0.1:808/service"
binding="netTcpBinding"
bindingConfiguration="MainBinding"
bindingName="MainBinding"
name="DefaultEndpoint"
contract="WcfService1.IService1" />
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
In this case, I have removed base address and provided complete service address (with out .svc path) but get a socket time out error. What's wrong in this case? Does the end point address always need the complete address with .svc when base address is not defined? If so, what could be the reason behind?
baseAddress
is just that, the base address for your endpoints (unless specified explicitly). So every <endpoint>
will inherit from <baseAddress>
(which is why they are usually ""
and "mex"
). e.g.
<host>
<baseAddresses>
<add baseAddress="http://127.0.0.1:1337/" />
</baseAddresses>
</host>
...
<endpoint address="" contract="MyService.IMyContract" ... />
<endpoint address="mex" contract="IMetadataExchange" ... />
You now have two endpoints:
http://127.0.0.1:1337/
- service endpointhttp://127.0.0.1:1337/mex
- metadata endpointBy exempting the <baseAddress>
you're requiring the <endpoints>
to both be fully qualified (including the mex (which is not)). e.g.
<host>
<baseAddresses/>
</host>
...
<endpoint address="net.tcp://127.0.0.1:1337/" contract="MyService.IMyContract" ... />
<endpoint address="http://127.0.0.1:1337/mex" contract="IMetadataExchange" ... />
You now have two different endpoints:
net.tcp://127.0.0.1:1337/
- service endpointhttp://127.0.0.1:1337/mex
- metadata endpointIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With