简体   繁体   English

MobileFirst V8.0.0,cordova客户端应用程序无法从JavaScriptSOAP获得响应(SOAP集成)

[英]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"
      }
    }

Check in MobileFirst Swagger 签入MobileFirst Swagger 在此处输入图片说明

Using parameter 使用参数
MobileFirst招摇

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 创建 probot.github 应用程序失败并出现错误:程序化 API 已在 npm v8.0.0 中删除 - Creation of probot.github app failing with Error: The programmatic API was removed in npm v8.0.0 Node.js v8.0.0-使用关键字搜索数组 - Node.js v8.0.0 - Search the an array using a keyword 无法从节点/快递获取成功响应数据/状态到我的客户端应用程序(反应):“referenceerror response is not defined” - can't get success response data/status from node/express to my client app(react): "referenceerror response is not defined" 从服务器获取SOAP响应 - Get the SOAP response from server 无法从目标C插件返回Ionic / Cordova应用程序错误 - Can't Get Error To Return To Ionic/Cordova App From Objective C Plugin 为什么在cordova应用程序中无法获得全球价值? - Why I can't get the global value in a cordova app? SubmitLoginForm()不会将数据发送到身份验证服务器-MobileFirst Cordova客户端 - submitLoginForm() does not send the data to the authentication server - MobileFirst Cordova client 无法从json响应中获取元素 - Can't get elements from json response 我无法从服务器获得响应 - I can't get a response from the server 无法从Angular $ resource获得响应 - Can't get response from Angular $resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM