我在两个程序上都有相同的应用程序配置
A - 当我运行它时服务本身,wcf Test Client启动
B - 使用 - new 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<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"
提前致谢
答案 0 :(得分:0)
猜测 - 如何向服务器端端点添加地址:
<endpoint address="" .... >
是的,基地址基本上定义了整个地址 - 但您仍应将地址添加到服务端点 - 即使它是空的。
答案 1 :(得分:0)
关于marc_s
请求我编写自己的自我编码代码..
我正在使用:
private void m_startServiceToolStripMenuItem_Click(object sender, EventArgs e)
{
using (Host = new ServiceHost(typeof(MyNameSpace.MyService)))
{
Host.Open();
}
}
在我将其添加到问题之前我尝试在没有using
部分的情况下更改它:
private void m_startServiceToolStripMenuItem_Click(object sender, EventArgs e)
{
Host = new ServiceHost(typeof(yNameSpace.MyService));
Host.Open();
}
现在正在工作!!
但是,不知怎的,它之前有效......
无论如何,谢谢大家: - )