从客户端使用out配置文件在WCF服务中实现的调用方法

时间:2013-08-15 15:41:18

标签: .net wcf wcf-binding

我在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>

1 个答案:

答案 0 :(得分:1)

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