我使用基於SOAP的服務請求創建了一個HTTP適配器。Worklight 6.1並解析MTOM肥皂響應
工作正常,但響應不是'xml'格式。
例如我的肥皂請求是採用以下
function getActions(username,password) {
var b64Auth = org.apache.commons.codec.binary.Base64.encodeBase64String(new java.lang.String(username+':'+password).getBytes());
var bAuth = "Basic " + b64Auth;
var request =
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ws="http://ws.tririga.com">
<soap:Header/>
<soap:Body>
<ws:getActionItems/>
</soap:Body>
</soap:Envelope>;
WL.Logger.debug("SOAP Request " + request);
var input = {
method : 'post',
returnedContentType : 'plain',
path : '/tririga/ws/TririgaWS',
headers: { Authorization: bAuth },
body: {
content: request.toString(),
//contentType: 'application/soap+xml; charset=utf-8',
contentType: 'text/xml; charset=utf-8',
},
};
return WL.Server.invokeHttp(input);
}
和WL.server.invokeHTTP後,從後端的響應是以下
{
"errors": [
],
"info": [
],
"isSuccessful": true,
"responseHeaders": {
"Cache-Control": "no-cache=\"set-cookie, set-cookie2\"",
"Content-Language": "en-US",
"Content-Type": "multipart\/related; type=\"application\/xop+xml\"; boundary=\"uuid:db4e0265-c5be-460f-9115-04804f4b61f2\"; start=\"<[email protected]>\"; start-info=\"application\/soap+xml\"",
"Date": "Mon, 05 May 2014 14:02:49 GMT",
"Expires": "Thu, 01 Dec 1994 16:00:00 GMT",
"Set-Cookie": "JSESSIONID=0000dD8NqkZhfe2PngKJm-H5egF:-1; Path=\/; HttpOnly",
"Transfer-Encoding": "chunked",
"X-Powered-By": "Servlet\/3.0"
},
"responseTime": 173,
"statusCode": 200,
"statusReason": "OK",
"text": "\n--uuid:db4e0265-c5be-460f-9115-04804f4b61f2\nContent-Type: application\/xop+xml; charset=UTF-8; type=\"application\/soap+xml\";\nContent-Transfer-Encoding: binary\nContent-ID: <[email protected]>\n\n<soap:Envelope xmlns:soap=\"http:\/\/www.w3.org\/2003\/05\/soap-envelope\"><soap:Body><ns1:getActionItemsResponse xmlns:ns1=\"http:\/\/ws.tririga.com\"><ns1:out><ns2:ActionItem xmlns:ns2=\"http:\/\/dto.ws.tririga.com\"><ns2:taskId>167023<\/ns2:taskId><ns2:workflowId>53990823<\/ns2:workflowId><\/ns2:ActionItem><ns2:ActionItem xmlns:ns2=\"http:\/\/dto.ws.tririga.com\"><ns2:taskId>167023<\/ns2:taskId><ns2:workflowId>53980223<\/ns2:workflowId><\/ns2:ActionItem><ns2:ActionItem xmlns:ns2=\"http:\/\/dto.ws.tririga.com\"><ns2:taskId>167023<\/ns2:taskId><ns2:workflowId>53848722<\/ns2:workflowId><\/ns2:ActionItem><ns2:ActionItem xmlns:ns2=\"http:\/\/dto.ws.tririga.com\"><ns2:taskId>167023<\/ns2:taskId><ns2:workflowId>53847639<\/ns2:workflowId><\/ns2:ActionItem><\/ns1:out><\/ns1:getActionItemsResponse><\/soap:Body><\/soap:Envelope>\n--uuid:db4e0265-c5be-460f-9115-04804f4b61f2--",
"totalTime": 176,
"warnings": [
]
}
什麼是解析「文本」值的最佳方法是什麼? xslt樣式表? javascript?
感謝您的幫助
隨着returnedContentType到「XML」,我有以下錯誤:「錯誤」:[ 「內容未在序言不允許的。」, 「無法從後端解析有效載荷(步驟:HttpRequest的)」 只有returnedContentType到'平原'返回沒有錯誤。 – freddut