SharePointでホストされる部分とプロバイダでホストされる部分を持つSharePointアドインを開発しています。私のプロバイダがホストする部分には、TaxonomyやSearchのようなものをインストールするサービスがいくつかあります。私はこれにC#CSOMを使用します。これは、プロバイダがホストするパートの唯一の目的です。アドインがインストールされると、AppInstalled Event Triggersがリモートイベント受信者を呼び出します。このリモートイベント受信者は、次にWCFサービスを1つずつ呼び出す必要があります。パラメータ付きの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