我在这两个程序上都有相同的应用程序配置
A - 服务本身,当我运行它时,wcf测试客户端启动。
乙 - 使用自宿主程序 - new ServiceHost(typeof(MyService)))
same app.config:wcftestclient work,selfHosting doesnot
那就是:
<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<StorageServiceInterface.IService1>
客户端的app.config:
<system.serviceModel>
<client>
<endpoint address="http://myIp/MyService"
binding="basicHttpBinding"
contract="StorageServiceInterface.IService1">
</endpoint>
</client>
</system.serviceModel>
当我运行selfhost程序和做host.open()
它并打开它,但是当我尝试调用一个方法,它告诉我说:
"No connection could be made because the target machine actively refused it 10.0.0.1:5999"
ofcourse当服务运行从WCF测试客户端,每件事情都起作用。 它怎么可能?
在此先感谢
你能告诉我们你的自托管应用程序的代码? – 2010-06-30 15:15:34