0

IBM MobileFirst Platform 7 で HTTP (SOAP) アダプターを使用しています。コンソールではすべて正常に動作しますが、実際のデバイスでアプリを実行しようとすると失敗し、Web サービスが呼び出されません。

Logcat には次のように表示されます。

05-05 17:33:11.012: W/PluginManager(13237): THREAD WARNING: exec() call to WLAuthorizationManagerPlugin.getClientInstanceIdHeader blocked the main thread for 173ms. Plugin should use CordovaInterface.getThreadPool().
05-05 17:33:11.032: D/wl.request(13237): WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://192.168.1.43:10080/Adapters/authorization/v1/clients/instance
05-05 17:33:11.072: D/dalvikvm(13237): GC_CONCURRENT freed 4707K, 24% free 19499K/25604K, paused 4ms+3ms, total 60ms
05-05 17:33:21.092: D/wl.certManager(13237): WLCertManager.clearKeystore in WLCertManager.java:258 :: Key store cleared.
05-05 17:33:21.122: D/NONE(13237): Client registration failed with error: {"status":500,"responseHeaders":{},"responseText":"","invocationContext":null}
05-05 17:33:21.132: E/NONE(13237): [/apps/services/api/CallingAdapters/android/query] failure. state: 500, response: undefined

実際のデバイスで HTTP アダプターを使用するには、どのような手順に従う必要がありますか?

これが私のコードです:

index.htm

<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>CallingAdapters</title>
<meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="css/main.css">
<script>
    window.$ = window.jQuery = WLJQ;
</script>
<script>
    function mSuccess(result) {

                var httpStatusCode = result.status;
                if (200 == httpStatusCode) {
                    var invocationResult = result.invocationResult;
                    var isSuccessful = invocationResult.isSuccessful;
                    if (invocationResult.isSuccessful) {
                        var CelsiusToFahrenheitResponse = invocationResult.CelsiusToFahrenheitResponse;
                        var res = CelsiusToFahrenheitResponse.CelsiusToFahrenheitResult;
                        alert("Success::::" + res);
                    } else {
                        alert("Error. isSuccessful=" + isSuccessful);
                    }
                }


    }
</script>
<script>
    function mFailure(result) {
        alert("Failure");
    }
</script>
<script>
    function callFunc() {
        var value = $('#input1').val()
                var invocationData = {
                    adapter : 'SOAPAdapter',
                    procedure : 'temperatureConvertor',
                    parameters : [ value ]
                };

        WL.Client.invokeProcedure(invocationData, {
            onSuccess : mSuccess,
            onFailure : mFailure,
        });
    }
</script>
</head>
<body style="display: none;">
    <!--application UI goes here-->
    Hello MobileFirst By Sravana Lakshmi

    <div>
        <input id="input1" type="number" />
    </div>
    <input type="submit" name="submit" onclick="callFunc()" />
    <script src="js/initOptions.js"></script>
    <script src="js/main.js"></script>
    <script src="js/messages.js"></script>

</body>
</html>

SOADAdapter.xml

<wl:adapter name="SOAPAdapter"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wl="http://www.ibm.com/mfp/integration"
    xmlns:http="http://www.ibm.com/mfp/integration/http">

    <displayName>SOAPAdapter</displayName>
    <description>SOAPAdapter</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
            <domain>www.w3schools.com</domain>
            <port>80</port>         
            <connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
            <socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
            <maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>   
        </connectionPolicy>
    </connectivity>

    <procedure name="temperatureConvertor"/>
</wl:adapter>

SOAPAdapter-impl.js

関数 temperatureConvertor(摂氏温度) {

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>
            <CelsiusToFahrenheit xmlns="http://www.w3schools.com/webservices/">
                <Celsius>{celsiusTemp}</Celsius>
            </CelsiusToFahrenheit>
        </soap:Body>
    </soap:Envelope>;

    var input = {
        method: 'post',
        returnedContentType: 'xml',
        path: '/webservices/tempconvert.asmx',
        body: {
            content: request.toString(),
            contentType: 'text/xml; charset=utf-8',
        },
    };

    var result = WL.Server.invokeHttp(input);

    return result.Envelope.Body;
};
4

1 に答える 1