適配器JS如何將參數傳遞給JS HTTP適配器在MobileFirst 8
function getCitiesByCountry(countryName)
{
var request =
var request=
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
<soapenv:Header/>
<soapenv:Body>
<web:GetCitiesByCountry>
<!--Optional:-->
<web:CountryName>INDIA</web:CountryName>
</web:GetCitiesByCountry>
</soapenv:Body>
</soapenv:Envelope>;
var input =
{
method: 'post',
returnedContentType: 'xml',
path: '/globalweather.asmx',
body: {
content: request.toString(),
contentType: 'text/json; charset=utf-8'
}
};
var result = MFP.Server.invokeHttp(input);
return result.Envelope.Body;
};
適配器XML
<displayName>JavaScriptSOAP</displayName>
<description>JavaScriptSOAP</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>www.webservicex.net</domain>
<port>80</port>
</connectionPolicy>
</connectivity>
<procedure name="getCitiesByCountry" secured ="false"/>
Index.js
function submitRequest()
{
var resourceRequest = new WLResourceRequest("adapters/JavaScriptSOAP/getCitiesByCountry", WLResourceRequest.POST);
resourceRequest.setQueryParameter("params", "['India']");
resourceRequest.send().then(
function(response) {
alert('response '+JSON.stringify(response.responseText));
},
function(response) {
alert("HTTP Failure "+JSON.stringify(response));
}
);
}
我需要傳遞參數到http適配器它包含國家名稱。我在索引js文件中包含國家名稱。在預覽應用程序時,我收到錯誤代碼415,
而且在控制檯我收到
[AUDIT ] CWWKS1100A: Authentication did not succeed for user ID test. An invalid user ID or password was specified.
[AUDIT ] CWWKS1100A: Authentication did not succeed for user ID test. An invalid user ID or password was specified.
[AUDIT ] CWWKS1100A: Authentication did not succeed for user ID test. An invalid user ID or password was specified.
我:
的Eclipse的Java EE IDE的Web開發。 版本:Mars.2版本(4.5.2) 版本ID:20160218-0600 Windows 7的
我有什麼認證給。如何克服錯誤?
我無法理解的問題。什麼是調用此適配器的客戶端代碼? –
Iam無法從客戶端代碼調用適配器(即index.js)。現在我也包含了index.js代碼。 – CodeWriter
何時發生此錯誤?你提到 - 編譯。編譯什麼 - 你的應用程序? –