我在這兩個程序上都有相同的應用程序配置
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