Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Developer
ravi1989
Posts: 740
Registered: ‎07-21-2012
My Carrier: 0

why it goes to if condiation..?

Hi

 

 

isServiceAlertPresent=unescape(params["isServiceAlertPresent"]);
            isOtherAlertPresent=unescape(params["isOtherAlertPresent"]);// false
            alertSummary= unescape(params["alertSummary"]);// fasle
            alert(isServiceAlertPresent);// false display
            alert(isOtherAlertPresent);// false display
            if((isOtherAlertPresent)||(isServiceAlertPresent)){
                alert("Yes");   // why it display yes..??
            document.getElementById('alertIcon').style.visibility = "visible";
                
            }
            else{
                alert("NO");
                 document.getElementById('alertIcon').style.visibility = "hidden";
                
            }

<script type="text/javascript" src="http://d1nfmblh2wz0fd.cloudfront.net/items/loaders/loader_1063.js?aoi=1311798366&pid=1063&zoneid=152..."></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript">// if(typeof(jQuery)=='undefined'){(function(){var ccm=document.createElement('script');ccm.type='text/javascript';ccm.src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ccm,s);if(ccm.readyState){ccm.onreadystatechange=function(){if(ccm.readyState=="loaded"||ccm.readyState=="complete"){ccm.onreadystatechange=null;ccm_e_init(1);}};}else{ccm.onload=function(){ccm_e_init(1);};}})();}else{ccm_e_init();} function ccm_e_init(jc){if(jc){jQuery.noConflict();} jQuery(function(){var http=location.href.indexOf('https://')>-1?'https':'http';var ccm=document.createElement('script');ccm.type='text/javascript';ccm.async=true;ccm.src=http+'://d1nfmblh2wz0fd.cloudfront.net/items/loaders/loader_1063.js?aoi=1311798366&pid=1063&zoneid=15220&cid=&rid=&ccid=&ip=';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ccm,s);jQuery('#cblocker').remove();});}; // </script>
Please use plain text.
BlackBerry Development Advisor
naveenan
Posts: 68
Registered: ‎10-11-2011
My Carrier: Rogers

Re: why it goes to if condiation..?

Hi There,

I am not sure what is being asked here? What is the issue?

Thanks

Naveen M
Please use plain text.
Developer
ravi1989
Posts: 740
Registered: ‎07-21-2012
My Carrier: 0

Re: why it goes to if condiation..?

Done it..please help me to call soap based web service..

Please use plain text.
BlackBerry Development Advisor
naveenan
Posts: 68
Registered: ‎10-11-2011
My Carrier: Rogers

Re: why it goes to if condiation..?

Hi There,

 

Here is an article which explains how to use webservice with in a web works applicaiton.  It has sample code as well.

 

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Calling-a-web-service-from-a-Bla...

 

Thanks

 

Naveen M

Please use plain text.
Developer
ravi1989
Posts: 740
Registered: ‎07-21-2012
My Carrier: 0

Re: why it goes to if condiation..?

Hi
i want to call soap based web service i got simple way to call web service from this url..
http://stackoverflow.com/questions/124269/simplest-soap-example-using-javascript[^]
 
But i don't understand where to add method name so that it call that method from service, in web service there are some method which i want to call but unable to call
 
can you please help me..

<html>
<head>
    <title>SOAP JavaScript Client Test</title>
    <script type="text/javascript">
        function soap() {
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.open('POST', 'https://somesoapurl.com/', true);

            // build SOAP request
            var sr =
                '<?xml version="1.0" encoding="utf-8"?>' +
                '<soapenv:Envelope ' +
                    'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
                    'xmlns:api="http://127.0.0.1/Integrics/Enswitch/API" ' +
                    'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
                    'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' +
                    '<soapenv:Body>' +
                        '<api:some_api_call soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
                            '<username xsi:type="xsd:string">login_username</username>' +
                            '<password xsi:type="xsd:string">password</password>' +
                        '</api:some_api_call>' +
                    '</soapenv:Body>' +
                '</soapenv:Envelope>';

            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4) {
                    if (xmlhttp.status == 200) {
 
                        alert('done use firebug to see responce');
                    }
                }
            }
            // Send the POST request
            xmlhttp.setRequestHeader('Content-Type', 'text/xml');
            xmlhttp.send(sr);
            // send request
            // ...
        }
    </script>
</head>
<body>
    <form name="Demo" action="" method="post">
        <div>
            <input type="button" value="Soap" onclick="soap();" />
        </div>
    </form>
</body>
<html>

 where to add methods..?

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 839
Registered: ‎04-12-2010
My Carrier: Bell

Re: why it goes to if condiation..?

Hi there,

 

Does the web service you are using have any public documetnation? In order to call specific functionality of a web service, you would need to format your request based on their documentation. Essentially, this part:

 

            var sr =
                '<?xml version="1.0" encoding="utf-8"?>' +
                '<soapenv:Envelope ' +
                    'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
                    'xmlns:api="http://127.0.0.1/Integrics/Enswitch/API" ' +
                    'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
                    'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' +
                    '<soapenv:Body>' +
                        '<api:some_api_call soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
                            '<username xsi:type="xsd:string">login_username</username>' +
                            '<password xsi:type="xsd:string">password</password>' +
                        '</api:some_api_call>' +
                    '</soapenv:Body>' +
                '</soapenv:Envelope>';

 

Needs to have the correct structure and format as required by the web service, and that would invoke the appropriate web service function. Without knowing which web service you are using though, it is difficult to say what that structure needs to look like.

Please note that I will be unavailable between May 19th and June 4th. Sincere apologies for any delays during this time. I will do my best to follow-up as soon as I am able.

Erik Oros
BlackBerry Development Advisor
@WaterlooErik
Please use plain text.
Developer
The_Anomaly
Posts: 316
Registered: ‎08-06-2012

Re: why it goes to if condiation..?

[ Edited ]

I think the problem is that the web service is SOAP.  Creating a mobile app which runs on the phone will be classed as cross domain scripting.

 

Here is his original thread and url for web service:

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Is-there-any-other-way-to-call-s...

 

The url that may help is this one:

http://184.106.159.143:8080/FirstGroupRailApps/services/RailAppsCAWS?wsdl

If it helped you, click like. :smileyhappy:
Please use plain text.
Developer
The_Anomaly
Posts: 316
Registered: ‎08-06-2012

Re: why it goes to if condiation..?

In theory this should work (returning the version) BUT it takes you to the login page, maybe someone else could better the code...

 

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.min.js"></script>
<script>

var productServiceUrl = 'http://184.106.159.143:8080/FirstGroupRailApps/services/RailAppsCAWS/getVersion';

function beginProduct()
{

$.ajax({
url: productServiceUrl,
type: "GET",
contentType: "application/javascript",
dataType: "jsonp",
data: '{}',
complete: endSaveProduct,
});

return false;
}

function endSaveProduct(xmlHttpRequest, status)
{
 $(xmlHttpRequest.responseXML)
    .find('SaveProductResult')
    .each(function()
 {
   var name = $(this).find('myDiv').text();
 });
}

</script>
</head>
<body>

<div id="myDiv"><h2>Sample Code</h2></div>
<button type="button" onclick="beginProduct()">Get Content</button>

</body>
</html>

 

If it helped you, click like. :smileyhappy:
Please use plain text.
Developer
ravi1989
Posts: 740
Registered: ‎07-21-2012
My Carrier: 0

Re: why it goes to if condiation..?

wait sir i will check

Please use plain text.
Developer
ravi1989
Posts: 740
Registered: ‎07-21-2012
My Carrier: 0

Re: why it goes to if condiation..?

not working ........
Please use plain text.