在PhoneGap的呼叫SOAP Web服务为Android [英] Call SOAP webservice in Phonegap for Android

查看:152
本文介绍了在PhoneGap的呼叫SOAP Web服务为Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要调用的 SOAP Web服务中的PhoneGap(Android版)

I want to call SOAP webservice in Phonegap(Android)

我已经尝试这个code,但在响应文本有未定义和状态错误

I've try this code but in Response text there is Undefined and Status Error

<!DOCTYPE>
<html>
<head>
    <title>SOAP JavaScript Client Test</title>
    <script type="text/javascript" src="../cordova.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">
        function soap() {


                $.ajax({
                    type: "POST",
                    url: "http://domain_Url/orabpel/default/XXNotificationListRetrieval/1.0",
                    dataType: "xml",
                    contentType: 'text/xml; charset=utf-8',
                    data: '<soap:Envelope'+
            'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"'+
            'xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'+
            '<soap:Header>'+
            '<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" soap:mustUnderstand="1">'+
            '<wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">'+
            '<wsse:Username>Hello</wsse:Username>'+
            '<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">world</wsse:Password></wsse:UsernameToken></wsse:Security>'+
            '</soap:Header>'+    
            '<soap:Body '+ 
            ' xmlns:ns1="http://xmlns.oracle.com/bpel/mobile/Notificationlist">'+           
            '<ns1:NotificationlistRetrievalREQ>'+                
            '<ns1:NotificationlistType>OFFER</ns1:NotificationlistType>'+
            '<ns1:Status>TODO</ns1:Status>'+
            '<ns1:Mode/>'+
            '</ns1:NotificationlistRetrievalREQ>'+
            '</soap:Body>'+
            '</soap:Envelope>';
                    success: processSuccess,
                    error: processError
                });

                function processSuccess(data, status, req) {
                    if (status == "success")
                    alert(req.responseText + " " + status);
                }

                function processError(data, status, req) {
                    alert(req.responseText + " " + status);
                }  
        }   

    </script>
</head>
<body>
    <form name="Demo" action="POST" method="post">
        <div>
            <input type="button" value="Soap" onclick="soap()" />
            <div id="response" />
        </div>
    </form>
</body>
<html>

我已经访问以下链接,但我没有得到令人满意的Answer.Everyone仅仅定义了不同的链接,但不给予适当的想法,因此它不能理解的,因为我是新来的PhoneGap。

I've visit following links but I don't get satisfactory Answer.Everyone just defines different links but don't give proper idea so It can't understandable because I am new to Phonegap.

<一个href=\"http://stackoverflow.com/questions/12346752/how-to-call-soap-web-services-in-phonegapandroid\">How调用SOAP Web服务中的PhoneGap(Android版)

如何调用基于SOAP的Web服务使用的PhoneGap和jQuery在Android的?

<一个href=\"http://stackoverflow.com/questions/12650123/how-to-call-android-soap-web-services-in-phonegapandroid\">How调用Android的SOAP Web服务中的PhoneGap(Android版)

如果我拿到样品code,那么这将是AP preciable,我使用Cordova.js 2.9.0

If I got Sample Code then it will be appreciable, I am using Cordova.js 2.9.0

推荐答案

我得到了我的问题的答案。有在传承一些问题 外型我的失​​误将 SOAPACTION setRequestHeader

I got Answer of My Question. there are some Problems in Passing Envelop and my mistakes in set SoapAction in setRequestHeader

下面是code

<!DOCTYPE>
<html>
<head>
    <title>SOAP JavaScript Client Test</title>
    <script type="text/javascript">
        function soap() {

            var xmlhttp = new XMLHttpRequest();
            xmlhttp.open("POST","http://domain_IP:port/orabpel/default/XXNotificationListRetrieval/1.0",true);

            var sr= "<?xml version='1.0' encoding='UTF-8'?>";
                sr+="<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">";
                sr+="<soap:Header>";    
                sr+="<wsse:Security xmlns:wsse=\"http:\//docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" soap:mustUnderstand=\"1\">";
                sr+="<wsse:UsernameToken xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">";
                sr+="<wsse:Username>HELLO<\/wsse:Username>";
                sr+="<wsse:Password Type=\"http:\//docs.oasis-open.org\/wss\/2004\/01\/oasis-200401-wss-username-token-profile-1.0#PasswordText\">world<\/wsse:Password>";
                sr+="<\/wsse:UsernameToken>";
                sr+="<\/wsse:Security>";
                sr+="<\/soap:Header>";  
                sr+="<soap:Body xmlns:ns1=\"http://xmlns.oracle.com/bpel/mobile/Notificationlist\">";
                sr+="<ns1:NotificationlistRetrievalREQ>";
                sr+="<ns1:NotificationlistType>Human-Offer<\/ns1:NotificationlistType>";
                sr+="<ns1:Status>TODO<\/ns1:Status>";
                sr+="<\/ns1:NotificationlistRetrievalREQ>";
                sr+="<\/soap:Body>";
                sr+="<\/soap:Envelope>";


            // Send the POST request
            xmlhttp.setRequestHeader("Accept", "application/xml", "text/xml", "\*/\*");
            xmlhttp.setRequestHeader("SOAPAction", "action_name");
            xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
            xmlhttp.send(sr);
            // send request
            // ...
                 xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4) {
                    if (xmlhttp.status == 200) {

                        //alert('done use firebug to see response');
                        alert('Response'+xmlhttp.responseText);
                    }
                    else
                    {
                        alert('Error '+xmlhttp.status);
                    }
                }
            }

        }
    </script>
</head>
<body>
    <form name="Demo" action="" method="post">
        <div>
            <input type="button" value="Soap" onclick="soap()" />
            <div id="response" />
        </div>
    </form>
</body>
</html>

这篇关于在PhoneGap的呼叫SOAP Web服务为Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆