namespace WindowsServiceApp
{
[ServiceContract(CallbackContract = typeof(IWcfServiceCallBack))]
public interface IWcfService
{
[OperationContract]
void getAuth(string auth);
[OperationContract]
double getPrice(string auth);
}
[ServiceContract]
public interface IWcfServiceCallBack
{
[OperationContract(IsOneWay = true)]
void getCallBack(string returnAurth);
}
}
namespace WindowsServiceApp
{
public class WcfService : IWcfService
{
public static string errorMessage = "";
public void getAuth(string auth)
{
WindowsServiceApp.WinService.FormScan formScan = new WinService.FormScan();
}
public double getPrice(string auth)
{
double a = 1;
return a;
}
}
}
namespace WindowsServiceApp
{
public partial class WinService : ServiceBase
{
ServiceHost host;
private static string errorMessage = "";
public WinService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
host = new ServiceHost(typeof(WcfService));
host.Open();
}
protected override void OnStop()
{
host.Close();
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="WindowsServiceApp.WcfServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBindingConfig"
clientBaseAddress="http://localhost:8733/" >
<security mode="None"/>
</binding>
</wsDualHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WindowsServiceApp.WcfServiceBehavior" name="WindowsServiceApp.WcfService">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBindingConfig" contract="WindowsServiceApp.IWcfService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Tuesday, December 1, 2015
WCF Duplex Communication in Windows Service
Subscribe to:
Comments (Atom)