โทรหาบริการเว็บ SOAP ใน Phonegap สำหรับ Android

ฉันต้องการโทรหา SOAP webservice ใน Phonegap (Android)

ฉันลองใช้รหัสนี้แล้ว แต่ใน ข้อความตอบกลับ มีข้อผิดพลาดที่ไม่ได้กำหนดและ สถานะ

<!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>

ฉันเข้าไปดูลิงก์ต่อไปนี้แล้ว แต่ฉันไม่ได้รับคำตอบที่น่าพอใจ ทุกคนแค่กำหนดลิงก์ที่แตกต่างกันแต่ไม่ได้ให้แนวคิดที่ถูกต้อง ดังนั้นจึงไม่สามารถเข้าใจได้เพราะฉันยังใหม่กับ Phonegap

วิธีเรียกใช้บริการ Soap Web ใน PhoneGap (Android)

จะเรียกบริการเว็บที่ใช้ SOAP โดยใช้ PhoneGap และ jquery ใน Android ได้อย่างไร

วิธีเรียกใช้บริการ Android Soap Web ใน PhoneGap (Android)

ถ้าฉันได้รับโค้ดตัวอย่างก็จะเห็นคุณค่า ฉันใช้ Cordova.js 2.9.0


person MDroid    schedule 24.09.2013    source แหล่งที่มา


คำตอบ (1)


ฉันได้รับคำตอบสำหรับคำถามของฉัน มีปัญหาบางอย่างในการส่ง Envelop และข้อผิดพลาดของฉันในชุด SoapAction ใน setRequestHeader

นี่คือรหัส

<!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>
person MDroid    schedule 24.09.2013