开发者

WCF - Beginners question on Address (of ABC)

I am new to WCF. Following is a question on WCF.

Suppose, I have a service defined as follows.

The host has two addresses. I usually click on the base address http://.... to generate proxy.

  1. When the proxy is generated, will it have address of http alone?
  2. How can I generate a proxy with net.tcp.
  3. Is there any article that explains the use of net.tcp with local host and ASP.NET?

Here's my config:

<service name="XXX.RRR.Common.ServiceLayer.开发者_JAVA百科MySL" behaviorConfiguration="returnFaults">
  <endpoint
      behaviorConfiguration="LargeEndpointBehavior"
      binding="netTcpBinding" bindingConfiguration="MessagingBinding" 
      contract="XXX.RRR.Common.ServiceLayer.IMySL" />
  <host>
    <baseAddresses>
       <add baseAddress="net.tcp://localhost:86/XXX/RRR/ManagerService" />
       <add baseAddress="http://localhost:76/XXX/RRR/ManagerService" /> 
    </baseAddresses>
  </host>
</service>

Thanks Lijo


What exactly is your issue here?? From your config, I see you don't have any address defined on the service endpoint - you need to supply one!

<service name="XXX.RRR.Common.ServiceLayer.MySL" behaviorConfiguration="returnFaults">
  <endpoint
      address=""
      behaviorConfiguration="LargeEndpointBehavior"
      binding="netTcpBinding" bindingConfiguration="MessagingBinding" 
      contract="XXX.RRR.Common.ServiceLayer.IMySL" />

When you create a client proxy against this service using the http address, then yes, the client side config will have the http endpoint as its address - something like:

<client>
  <endpoint name="Default"
            address="http://localhost:76/XXX/RRR/ManagerService"
            binding="basicHttpBinding" 
            contract="XXX.RRR.Common.ServiceLayer.IMySL" />
</client>

You can simply manually add a second endpoint to the config - or use the Wcf Configuration Tool in Visual Studio to do that! - like so:

<client>
  <endpoint name="Default"
            address="http://localhost:76/XXX/RRR/ManagerService"
            binding="basicHttpBinding" 
            contract="XXX.RRR.Common.ServiceLayer.IMySL" />
  <endpoint name="TCP"
            address="net.tcp://localhost:86/XXX/RRR/ManagerService"
            binding="netTcpBinding" 
            contract="XXX.RRR.Common.ServiceLayer.IMySL" />
</client>

However, with the current configuration you have on the service side, you only expose a single netTcp endpoint on the server - so you won't even be able to connect to the server using HTTP to create your client proxy.....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜