[英]MobileFirst V8.0.0 , cordova client app can't get response from JavaScriptSOAP (SOAP integration)
MobileFirst V8.0.0 , cordova client app can't get response from JavaScriptSOAP (SOAP Integration): MobileFirst V8.0.0,cordova客户端应用程序无法从JavaScriptSOAP(SOAP集成)获得响应:
I have a problem accessing a JavaScriptSOAP (Example Adapter) from a Cordova client app, there is no response from Adapter JavaScriptSOAP. 我从Cordova客户端应用程序访问JavaScriptSOAP(示例适配器)时遇到问题,适配器JavaScriptSOAP没有响应。
I'm using Mobilefirst Server 8.0 Development Foundation kit. 我正在使用Mobilefirst Server 8.0开发基础套件。
Question : What is the reason I can't get the response, does it requires to setting the security again, if security where to set it. 问题 :我无法获得响应的原因是什么,是否需要再次设置安全性(如果在哪里设置安全性)?
1) Client App Cordova (index.js) 1)客户端应用程序Cordova(index.js)
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.getElementById("btn_submit").addEventListener('click', app.submitRequest);
},
submitRequest:function() {
var resourceRequest = new WLResourceRequest("/adapters/JavaScriptSOAP/getWeatherInfo", WLResourceRequest.GET);
resourceRequest.setQueryParameter("params", "['Washington', 'United States']");
resourceRequest.send().then(app.onSuccess, app.onFailure);
},
onSuccess: function(response) {
WL.Logger.info("Success: " + response.responseText);
window.plugins.spinnerDialog.hide();
var $result = $(response.invocationResult.Envelope.Body.GetWeatherResponse.GetWeatherResult);
var weatherInfo = {
location: $result.find('Location').text(),
time: $result.find('Time').text(),
wind: $result.find('Wind').text(),
temperature: $result.find('Temperature').text(),
};
document.getElementById("div_result").innerHTML= weatherInfo;
},
onFailure: function(response) {
WL.Logger.info("Failure: " + JSON.stringify(response));
window.plugins.spinnerDialog.hide();
var resultText = "Failure: " + JSON.stringify(response);
document.getElementById("div_result").innerHTML = resultText;
}
};
2) Java Script Adapter - JavaScriptSOAP (from GITHUB example) 2)Java脚本适配器-JavaScriptSOAP(来自GITHUB示例)
2.1) JavascriptSOAP-impl.js 2.1)JavascriptSOAP-impl.js
function getWeatherInfo(cityName, countryName) {
var request =
<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>
<GetWeather xmlns="http://www.webserviceX.NET">
<CityName>{cityName}</CityName>
<CountryName>{countryName}</CountryName>
</GetWeather>
</soap:Body>
</soap:Envelope>;
var input = {
method: 'post',
returnedContentType: 'xml',
path: '/globalweather.asmx',
body: {
content: request.toString(),
contentType: 'text/xml; charset=utf-8'
}
};
var result = MFP.Server.invokeHttp(input);
var xmlDoc = new XML(result.Envelope.Body.GetWeatherResponse.GetWeatherResult);
var weatherInfo = {
Location: xmlDoc.Location.toString(),
Time: xmlDoc.Time.toString(),
Wind: xmlDoc.Wind.toString(),
Temperature: xmlDoc.Temperature.toString()
};
MFP.Logger.debug("This is a debug message from a JavaScript adapter" + weatherInfo.Temperature);
// return result.Envelope.Body;
return weatherInfo;
};
2.2) adapter.xml 2.2)adapter.xml
<mfp:adapter name="JavaScriptSOAP"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mfp="http://www.ibm.com/mfp/integration"
xmlns:http="http://www.ibm.com/mfp/integration/http">
<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"/>
<procedure name="getWeatherInfo"/>
</mfp:adapter>
Are you getting any error (kindly mention if any) ? 您是否遇到任何错误 (如果有的话,请提一下)? Which Response Code you are getting ?
您将获得哪个响应代码 ?
After deploying adapter, I am assuming you are getting response code : 200 部署适配器后,我假设您正在获取响应代码: 200
But Data not found in "GetWhetherResult". 但是在“ GetWhetherResult”中找不到数据。
you are getting Response Body as: 您得到的响应正文为:
{
"isSuccessful": true,
"GetWeatherResponse": {
"xmlns": "http://www.webserviceX.NET",
"GetWeatherResult": "Data Not Found"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.