12.13 リポジトリのディレクトリを削除するサンプル(WCF)
概要
リポジトリのディレクトリを削除するサンプルプログラムです
ソースサンプル
<biz-Stream_home>/sample/soap_client/dotNET/wcf/WSS_WCF_Sample12.aspx.cs
using System; using System.ServiceModel; using System.ServiceModel.Channels; using System.Web; using BizStreamWebApplication.CmsServiceReference; namespace BizStreamWebApplication { public partial class WSS_WCF_Sample12 : System.Web.UI.Page { // Webサービスサーバのホスト名 const string WSS_HOST_NAME = "wsssrv"; // Webサービスのエンドポイントプリフィックス const string WSS_SERVICE_LOCATION = "http://" + WSS_HOST_NAME + ":8080/axis2/services"; // BASIC認証のユーザ名 const string USER_NAME = "bizuser1"; // BASIC認証のパスワード const string PASSWORD = "bizuser1"; // 監査ロギング用のユーザ定義 const string USER_DEF = "AAA"; // 削除するフォルダパス const string TARGET_FOLDER_PATH = "/Sample12_WCF"; protected void Page_Load(object sender, EventArgs e) { // リポジトリ内のディレクトリを削除 removeDir(); // ブラウザに結果を表示 Response.Clear(); Response.ContentType = "text/html;charset=UTF-8"; Response.Write("<HTML><HEAD><TITLE>WSS_WCF_Sample12</TITLE></HEAD><BODY>"); Response.Write("正常終了しました。<BR>"); Response.Write("リポジトリから削除されたディレクトリ: " + TARGET_FOLDER_PATH); Response.Write("</BODY></HTML>"); Response.Flush(); HttpContext.Current.ApplicationInstance.CompleteRequest(); } private success removeDir() { // クライアントを生成 cmsPortTypeClient client = new cmsPortTypeClient("CmsSOAP11port", WSS_SERVICE_LOCATION + "/cms?UserDef=" + USER_DEF); // 認証の設定 BindingElementCollection elements = client.Endpoint.Binding.CreateBindingElements(); elements.Find<HttpTransportBindingElement>().AuthenticationScheme = System.Net.AuthenticationSchemes.Basic; client.ClientCredentials.UserName.UserName = USER_NAME; client.ClientCredentials.UserName.Password = PASSWORD; // MTOMを有効化 elements.Remove<TextMessageEncodingBindingElement>(); MtomMessageEncodingBindingElement mtom = new MtomMessageEncodingBindingElement(); mtom.ReaderQuotas.MaxStringContentLength = 100000; elements.Insert(0, mtom); elements.Find<HttpTransportBindingElement>().KeepAliveEnabled = false; client.Endpoint.Binding = new CustomBinding(elements); // リクエストメッセージの作成 deleteRequest request = new deleteRequest(); request.Value = TARGET_FOLDER_PATH; // リクエストを送信 return client.delete(request); } } }