0

我有一个托管在 dll 中的 WCF 服务,我使用 SvcUtil.exe 生成了代理代码,下面是我的客户端代码,

BasicHttpBinding binding = new BasicHttpBinding();
            binding.Security.Mode = BasicHttpSecurityMode.None;
            EndpointAddress epa = new EndpointAddress("http://localhost:8001/MyApplication/Deploy/DeployService/");
            DeployClient client = new DeployClient(binding, epa);
            deployStatus = client.Deploy(myStringArgument, true);

当我执行此操作时,我收到错误

在 [http://localhost:8001/MyApplication/Deploy/DeployService/] 上没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的

服务配置文件是,

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <!-- Configurable client send timeout, in seconds  -->
    <add key="DasClientSendTimeoutSeconds" value="1500" />
  </appSettings>
  <system.web>
    <compilation debug="false" />
  </system.web>
  <!-- -->
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding" sendTimeout="00:10:00" transferMode="StreamedRequest" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxStringContentLength="2147483647" />
          <!-- Security mode to use when clients are connecting to this Service. -->
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <client />
    <!--         
        <diagnostics>
            <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="false"/>
        </diagnostics>
        -->
    <services>
      <service behaviorConfiguration="DeployTarget.DeployBehavior" name="MyApplication.Deploy.DeployService">
        <endpoint address="http://localhost:8001/MyApplication/Deploy/DeployService/mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange" />
        <endpoint address="net.tcp://localhost:8002/MyApplication/Deploy/DeployService/" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" name="TcpEndpoint" contract="MyApplication.Common.Interfaces.IDeploy" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8001/MyApplication/Deploy/DeployService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DeployTarget.DeployBehavior">
          <!-- To avoid disclosing metadata information, 
                         set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value 
                         below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
</configuration>
4

1 回答 1

1

您的服务设置为使用 NetTcp,但客户端使用的是 Basic Http。如果您希望客户端和服务进行通信,绑定协议必须匹配。

于 2013-08-15T15:55:29.420 回答