調用WCF服務我正在開發一個SharePoint外掛程序,它具有SharePoint託管部分和提供程序託管部分。在提供商託管的部分中,我有幾個安裝了分類和搜索等幾項服務的服務。我爲此使用C#CSOM。這是提供者託管部分的唯一目的。當插件安裝時,會調用遠程事件接收器的AppInstalled事件觸發器。這個遠程事件接收器應該一個接一個地調用我的WCF服務。使用參數
現在我實際的問題:我目前使用這種方法來消耗我的服務:
var taxBinding = new BasicHttpBinding();
var taxEndpoint = new EndpointAddress(remoteUrl.ToString() + "/Services/TaxonomySetupService.svc");
var taxChannelFactory = new ChannelFactory<ISetupService>(taxBinding, taxEndpoint);
ISetupService taxClient = null;
try
{
taxClient = taxChannelFactory.CreateChannel();
taxClient.SetAppWebUrl(appWebUrl.ToString());
if (!taxClient.IsInstalled())
taxClient.Install();
string logs = taxClient.GetLogs();
((ICommunicationObject)taxClient).Close();
}
catch (Exception ex)
{
if (taxClient != null)
{
((ICommunicationObject)taxClient).Abort();
}
}
ISetupService:
[ServiceContract]
public interface ISetupService
{
string OpenText { get; }
string DoneText { get; }
string AppWebUrl { get; set; }
[OperationContract]
bool IsInstalled();
[OperationContract]
void SetLogComponent(LogList logList);
[OperationContract]
void SetAppWebUrl(string url);
[OperationContract]
void WriteToLog(string message);
[OperationContract]
string GetLogs();
[OperationContract]
void Install();
}
我的解決方案沒有,雖然,所以我採用這種做法尋找更好的東西。具體來說,我需要將一個ClientContext對象傳遞給我的ISetupService構造函數。這裏最簡單的方法是什麼?
你能更具體地解釋你想要解決什麼嗎? – jtabuloc
我正在尋找類似於http://stackoverflow.com/questions/21623432/how-to-pass-multiple-parameter-in-wcf-restful-service的東西,只是我想將我的參數傳遞給我的構造函數,不是一種方法。 – LeonidasFett