3

我想使用 netTcpBinding 和 basicHttpBinding 提供相同的接口。我还想为两个端点提供 wsdl。当我访问时http://localhost:9876/TestService/,我得到了包含 Tcp 端点信息的 mex 端点http://localhost:9876/TestService/?wsdl,但地址http://localhost:9876/TestService/ws没有响应,我不明白为什么。我有基地址和相对地址。有人可以帮我指出缺少的东西吗?现在,我只是在尝试使用 TestImplementation 服务,而我还没有搞乱 MessaginImplementation 服务。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="SimpleBinding" />
            </basicHttpBinding>
            <netTcpBinding>
                <binding name="DefaultTCPBinding" transactionFlow="true" />
            </netTcpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="MetadataBehavior">
                    <serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding"
                        httpGetBindingConfiguration="" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="MetadataBehavior" name="CompanyX.AppServer.Implementation.TestImplementation">
                <endpoint address="" binding="netTcpBinding" bindingConfiguration="DefaultTCPBinding"
                    name="TestTCPEndpoint" contract="CompanyX.AppServer.Interfaces.ITest" />
                <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
                    name="TestMex" contract="IMetadataExchange" />
                <endpoint address="/ws" binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
                    name="Test" contract="CompanyX.AppServer.Interfaces.ITest" />
                <host>
                    <baseAddresses>
                        <add baseAddress="net.tcp://localhost:9878/TestService" />
                        <add baseAddress="http://localhost:9876/TestService/" />
                    </baseAddresses>
                </host>
            </service>
            <service behaviorConfiguration="MetadataBehavior" name="CompanyX.AppServer.Implementation.MessaginImplementation">
                <endpoint address="" binding="netTcpBinding" bindingConfiguration="DefaultTCPBinding"
                    name="MessagingTCPEndpoint" contract="CompanyX.AppServer.Interfaces.IMessaging" />
                <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
                    name="MessagingMex" contract="CompanyX.AppServer.Interfaces.IMessaging" />
                <host>
                    <baseAddresses>
                        <add baseAddress="net.tcp://localhost:9878/MessagingService" />
                        <add baseAddress="http://localhost:9876/MessagingService" />
                    </baseAddresses>
                </host>
            </service>
        </services>
    </system.serviceModel>
</configuration>
4

2 回答 2

1

这是我的菜鸟错误。它实际上是正确的。答案在下面的帖子中。当我点击基本 HTTP 类时,我只得到来自浏览器的响应,但是使用这个 wsdl,我可以连接两个绑定。

于 2010-12-11T02:20:02.527 回答
0

我怀疑您的服务端点地址是错误的:

<endpoint address="/ws" binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
                name="Test" contract="CompanyX.AppServer.Interfaces.ITest" />

由于它是一个相对地址(添加到您的基地址),它应该只是ws- 没有前导正斜杠:

<endpoint name="Test" 
          address="ws" 
          binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
          contract="CompanyX.AppServer.Interfaces.ITest" />

尝试不使用正斜杠!应该这样工作。

于 2010-12-10T20:42:32.200 回答