JavaScriptのwebpartをSharepoint Frameworkに書き直そうとしています。SharePoint Framework httpClient.post to _vti_bin/lists.asmx response
このウェブパーツでは、定期的な予定が入っているカレンダーリストからすべてのイベントを取得するために、/_vti_bin/Lists.asmxの石鹸ポストを作成する必要があります。
javascriptのコードは、この
wsURL = webUrl + "/_vti_bin/Lists.asmx";
var xmlCall =
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Body>" +
"<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
"<listName>" + calendarList + "</listName>" +
"<query>" +
"<Query>" +
"<Where>" +
"<DateRangesOverlap>" +
"<FieldRef Name=\"EventDate\" />" +
"<FieldRef Name=\"EndDate\" />" +
"<FieldRef Name=\"RecurrenceID\" />" +
"<Value Type='DateTime'><Year/></Value>" +
"</DateRangesOverlap>" +
"</Where>" +
"</Query>" +
"</query>" +
"<queryOptions>" +
"<QueryOptions>" +
"<ExpandRecurrence>TRUE</ExpandRecurrence>" +
"</QueryOptions>" +
"</queryOptions>" +
"</GetListItems>" +
"</soap:Body></soap:Envelope>";
var result = [];
$.ajax({
url: wsURL,
type: "POST",
dataType: "xml",
async: false,
data: xmlCall,
complete: function (xData, status) {
if (status === "success") {
var root = $(xData.responseText);
root.find("listitems").children().children().each(function() {
$this = $(this);
var ids = $this.attr("ows_UniqueId").split(";");
var rec = $this.attr("ows_fRecurrence");
result.push({
"StartTime": $this.attr("ows_EventDate"),
"EndTime": $this.attr("ows_EndDate"),
"Title": $this.attr("ows_Title"),
"Recurrence": (rec === "1" ? true : false),
"Description": $this.attr("ows_Description"),
"Guid": ids[1],
"Id": ids[0],
});
});
}
},
contentType: "text/xml; charset=\"utf-8\""
});
return result;
};
のように見えます。しかし、今、私はtypescriptですで、このコードを書き換えるしようとしているが、私は戻ってresponseTextを取得するように見えることはできませんか?
これは私が活字体で私のSharepointのフレームワークから石鹸Webサービスへの投稿を行うとバックXML応答を取得できますか私の活字体の機能
private makeRequest(listName: string): Promise<HttpClientResponse> {
let wsURL = this.context.pageContext.web.absoluteUrl + "/_vti_bin/Lists.asmx";
var xmlCall =
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Body>" +
"<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
"<listName>" + listName + "</listName>" +
"<query>" +
"<Query>" +
"<Where>" +
"<DateRangesOverlap>" +
"<FieldRef Name=\"EventDate\" />" +
"<FieldRef Name=\"EndDate\" />" +
"<FieldRef Name=\"RecurrenceID\" />" +
"<Value Type='DateTime'><Year/></Value>" +
"</DateRangesOverlap>" +
"</Where>" +
"</Query>" +
"</query>" +
"<queryOptions>" +
"<QueryOptions>" +
"<ExpandRecurrence>TRUE</ExpandRecurrence>" +
"</QueryOptions>" +
"</queryOptions>" +
"</GetListItems>" +
"</soap:Body></soap:Envelope>";
const requestHeaders: Headers = new Headers();
requestHeaders.append('Content-type', "text/xml; charset=\"utf-8\"");
const httpClientOptions: IHttpClientOptions = {
body: xmlCall,
headers: requestHeaders
};
console.log("About to make REST API request.");
return this.context.httpClient.post(
wsURL,
HttpClient.configurations.v1,
httpClientOptions)
.then((response: HttpClientResponse) => {
console.log("REST API response received.");
console.log(response);
console.log(response.text());
console.log(response.json());
debugger;
return response.json();
});
}
のですか?