Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
相同的app.config:wcftestclient工作,自托管不工作_Wcf_App Config - Fatal编程技术网

相同的app.config:wcftestclient工作,自托管不工作

相同的app.config:wcftestclient工作,自托管不工作,wcf,app-config,Wcf,App Config,我在两个程序上都有相同的应用程序配置 A-服务本身运行时,wcf测试客户端启动。 B-使用新ServiceHost(typeof(MyService))的自宿主程序 这是: <services> <service name="MyNameSpace.MyService" behaviorConfiguration="MyService.Service1Behavior"> <host> <baseAddres

我在两个程序上都有相同的应用程序配置
A-服务本身运行时,wcf测试客户端启动。
B-使用新ServiceHost(typeof(MyService))的自宿主程序

这是:

<services>
  <service name="MyNameSpace.MyService"
           behaviorConfiguration="MyService.Service1Behavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:5999/MyService"/>
      </baseAddresses>
    </host>
    <endpoint
          binding="basicHttpBinding"
          contract="StorageServiceInterface.IService1"
          bindingConfiguration="MyBasicHttpBinding"
          name="basicEndPoint">

      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>


<bindings>
  <basicHttpBinding>
    <binding name="MyBasicHttpBinding">
      <security mode="None">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>


<behaviors>
  <serviceBehaviors>
    <behavior name="HeziService.Service1Behavior">         
      <serviceMetadata httpGetEnabled="true"/>          
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>


客户端使用
ClientBase

客户端app.config:

<system.serviceModel> 
    <client>
        <endpoint address="http://myIp/MyService"
                  binding="basicHttpBinding"
                  contract="StorageServiceInterface.IService1">                
        </endpoint>
    </client>
</system.serviceModel>

当我运行selfhost程序并执行host.open()时
它确实打开了它,但当我尝试调用一个方法时,它告诉我:

“无法建立连接,因为目标计算机主动拒绝了它10.0.0.1:5999”

当然,当服务从WCF测试客户端运行时,一切都正常工作。 怎么可能呢


提前感谢

猜猜看-向服务器端端点添加地址如何:

<endpoint address="" .... >

是的,基址基本上定义了整个地址-但是您仍然应该将地址添加到您的服务端点-即使它是空的。

奇怪的事情:

关于要求我编写selfhost程序代码的marc_

我使用的是:

private void m_startServiceToolStripMenuItem_Click(object sender, EventArgs e)  
{  
    using (Host = new ServiceHost(typeof(MyNameSpace.MyService)))  
    {  
        Host.Open();  
    }  
}  
在将其添加到问题之前,我尝试在不使用
部分的情况下更改它:

private void m_startServiceToolStripMenuItem_Click(object sender, EventArgs e)  
{  
    Host = new ServiceHost(typeof(yNameSpace.MyService));  
    Host.Open();  
}
现在它工作了

但是,不知怎么的,它以前是有效的…

无论如何,谢谢大家:-)

你能给我们看一下你的自托管应用程序的代码吗?好的,是的,正在使用()。。。。将在关闭时销毁主机}并将其处置。所以这肯定行不通。。。。