0
我是WCF新手。我創建了一個新的WCF服務,它有一個名爲SendFax()的方法。它運行在Windows服務上。我希望其他用戶使用這種方法,但如何?我使用installutil.exe安裝了Windows服務,現在它正在運行。我想我的WCF服務正在偵聽。我怎樣才能達到這項服務?我的Windows服務代碼是在這裏:如何使用Windows服務上運行的WCF服務
public partial class WCFWinService : ServiceBase
{
ServiceHost serviceHost;
public WCFWinService()
{
InitializeComponent();
ServiceName = "Digiturk FaxPro WCF";
}
protected override void OnStart(string[] args)
{
if (serviceHost != null)
{
serviceHost.Close();
}
serviceHost = new ServiceHost(typeof(FaxPro.WCFWindowsService.WCFWinService));
serviceHost.Open();
}
protected override void OnStop()
{
if (serviceHost != null)
{
serviceHost.Close();
serviceHost = null;
}
}
}
WCF接口代碼:
[ServiceContract]
public interface IWCFService
{
[OperationContract]
void SendFax(....);
}
WCF服務代碼:
public class WCFService : IWCFService
{
public void SendFax(...)
{ ... }
有什麼建議?
App.Config中是這裏
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWCFService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8733/Design_Time_Addresses/Digiturk.FaxPro.WcfServiceLibrary/Service1/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFService"
contract="localhost.IWCFService" name="BasicHttpBinding_IWCFService" />
</client>
</system.serviceModel>
</configuration>
您可以在定義的地址 - 「http:// ServerName:8733/Design_Time_Addresses/Digiturk.FaxPro.WcfServiceLibrary/Service1 /'連接到此服務。它是一個** SOAP **服務 - 因此您需要一個支持SOAP的測試工具,如SoapUI或WCF Test Client(只是瀏覽器不工作)。您可以通過在URL中添加'?wsdl'來獲取上述地址的服務的WSDL –