wcftestclient失败,但仅在远程计算机上

时间:2010-10-20 23:01:36

标签: wcf

我已经启动并运行了一个wcf“自托管”服务,当我在机器之间进行通信时,会收到The remote server returned an unexpected response: (405) Method not allowed.消息。

这似乎只在运行连接到远程计算机的WCF测试客户端时发生。在服务器上运行时,一切都很好。

我认为它与安全性有关,但我不确定在哪里看。

有人能指出我错过了什么或做错了吗?

下面是我的服务器配置文件

<system.serviceModel>
        <protocolMapping>
            <remove scheme="http" />
            <add scheme="http" binding="customBinding" bindingConfiguration="gzipCompression" />
        </protocolMapping>
        <bindings>
            <customBinding>
                <binding name="gzipCompression">
                    <gzipMessageEncoding />
                    <httpTransport maxReceivedMessageSize="2147483647" />
                </binding>
            </customBinding>
        </bindings>
        <extensions>
            <bindingElementExtensions>
                <add name="gzipMessageEncoding" type="Compression.GZIP.GZipMessageEncodingElement, Compression, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
            </bindingElementExtensions>
        </extensions>
        <behaviors>
            <!--<serviceBehaviors>
                <behavior name="CadServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"
                        httpGetBinding="" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>-->
        </behaviors>
        <services>
            <service behaviorConfiguration="CadServiceBehavior" name="CadServiceLibrary.CadServiceContract">
                <endpoint address="com" binding="customBinding" bindingConfiguration="gzipCompression"
                    name="com" contract="CadServiceLibrary.CadServiceContract" />
                <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
                    name="mex" contract="IMetadataExchange" />
                <endpoint binding="wsHttpBinding" bindingConfiguration="" name="ws"
                    contract="CadServiceLibrary.CadServiceContract" />
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost/CadServices" />
                        <add baseAddress="https://localhost:450/CadServices" />
                    </baseAddresses>
                </host>
            </service>
        </services>
    </system.serviceModel>

1 个答案:

答案 0 :(得分:0)

我以前见过这个,虽然不确定这是不是你的问题:

而不是localhost,请输入您的服务器名称或IP地址。如果是IP地址,请确保在IIS中选择了相同的IP地址(我假设您在IIS中托管它)。

当使用localhost时,我在过去很难从远程计算机访问它 - 尽管在localhost上监听可以正常使用TCP。