★★★ 大侠们救命!!!客户端 和 WCF 服务器端 在一台机器上,客户端 和 服务器端 可以正常进行数据交流,分到俩台机器上就不行,为什么?WCF 服务器端用的是ServiceHost启动.相关代码如下???? ★★★
客户端 和 服务器端 在一台机器上,客户端 和 服务器端 可以正常进行数据交流,分到俩台机器上就不行,为什么?WCF 服务器端用的是ServiceHost启动.
启动代码如下:
host.cs:
public static void Main( )
{
Uri baseAddress = new Uri("http://localhost:8000/WCF/MyService");
ServiceHost host = new ServiceHost(typeof(MyService), baseAddress);
WfWcfExtension wfWcfExtension = new WfWcfExtension("WorkflowRuntimeConfig");
host.Extensions.Add(wfWcfExtension);
host.Open();
Console.WriteLine("WCF service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
host.Close();
}
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="WorkflowRuntimeConfig" type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</configSections>
<system.serviceModel>
<services>
<service name="WCF.MyService" behaviorConfiguration="WCF.Service1Behavior">
<endpoint address ="http://localhost:8000/WCF/MyService" binding="wsHttpBinding" contract="WCF.IMyService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCF.Service1Behavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
MyService.cs:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MyService : IMyService
{
}
IMyService.cs:
[ServiceContract()]
public interface IMyService
{
[OperationContract]
string GetSearchInfo();
}