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.

inside custom component

Web and WebWorks Development

Reply
Developer
Posts: 70
Registered: ‎04-08-2011
My Device: BB 4 and BB 5.0
My Carrier: BB Curve

Re: AJAX Problem

I'm still getting nothing:

<access uri="*" subdomains="true"/>

is it working on your simulator?

Regular Contributor
Posts: 83
Registered: ‎04-29-2011
My Device: 9300 Curve
My Carrier: TIM

Re: AJAX Problem

I use ajax in my app to consume webservice

 

here's part of the code:

 

SOAPClient._sendSoapRequest = function(url, port, method, parameters, wsdl)
{
   pl = parameters;
   
	// get namespace
	var ns = (wsdl.documentElement.attributes["targetNamespace"] + "" == "undefined") ? wsdl.documentElement.attributes.getNamedItem("targetNamespace").nodeValue : wsdl.documentElement.attributes["targetNamespace"].value;
	// build SOAP request
	var sr = 
				"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" +
				"<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>" +
				"<" + method + " xmlns=\"" + ns + "\">" +
				pl.toXml() +
				"</" + method + "></soap:Body></soap:Envelope>";
	// send request
	var xmlHttp = parent.getNetworkUtils();
	var wsPort = SOAPClient._getPortUrl(wsdl, port);
	if (SOAPClient.userName && SOAPClient.password){
		//TODO: xmlHttp.open("POST", wsPort, async, SOAPClient.userName, SOAPClient.password);
		// Some WS implementations (i.e. BEA WebLogic Server 10.0 JAX-WS) don't support Challenge/Response HTTP BASIC, so we send authorization headers in the first request
		xmlHttp.setRequestHeader("Authorization", "Basic " + SOAPClient._toBase64(SOAPClient.userName + ":" + SOAPClient.password));
	}
	var soapaction = ((ns.lastIndexOf("/") != ns.length - 1) ? ns + "/" : ns) + method;
	xmlHttp.setRequestHeader("SOAPAction", soapaction);
	xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=iso-8859-1");
	var responseXML = xmlHttp.postData(wsPort, "POST", sr);
	parser = new DOMParser();
	responseDoc = parser.parseFromString(responseXML, "text/xml");
	var o = null;
	var nd = SOAPClient._getElementsByTagName(responseDoc, method + "Result");

        if(nd.length == 0)
          nd = SOAPClient._getElementsByTagName(responseDoc, method + "Return");

	if(nd.length == 0)
	    nd = SOAPClient._getElementsByTagName(responseDoc, method + "Response");	// Maker web service

	if(nd.length == 0)
		nd = SOAPClient._getElementsByTagName(responseDoc, "return");	// PHP web Service?

	if(nd.length == 0)
		nd = SOAPClient._getElementsByTagName(responseDoc, "Return");
	if(nd.length == 0) {
		if(responseDoc.getElementsByTagName("faultcode").length > 0)
		{
		    throw new Error(500, responseDoc.getElementsByTagName("faultstring")[0].childNodes[0].nodeValue);			
		} else {
			nd = responseDoc.documentElement.childNodes;
			o = SOAPClient._soapresult2object(nd[0], wsdl);
		}
	}
	else
		o = SOAPClient._soapresult2object(nd[0], wsdl);
	return o;
}

 

I get the code from some italian website, forgot the name... but it's working.. at least the last time i checked was ok Smiley Tongue

Márcio Saeger - Software Engineer, Softwell Solutions
Highlighted
Developer
Posts: 70
Registered: ‎04-08-2011
My Device: BB 4 and BB 5.0
My Carrier: BB Curve

Re: AJAX Problem

Is there any special configuration of the simulator, This app is developed by



I'm using simulator which I got with sdk, and I have changed by JRE Security policy for BBM integration.

 

http://208.74.204.192/t5/Web-and-WebWorks-Development/Sample-Code-RSS-Reader/ta-p/589890

 

And its also giving "Response not found, connection timeout"

Retired
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: AJAX Problem

If your BlackBerry (NOT Playbook) simulator cannot access the internet at all the most likely reason is you do not have the MDS Simulator running at the same time. You can find it in the mds folder of the SDK.



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Developer
Posts: 70
Registered: ‎04-08-2011
My Device: BB 4 and BB 5.0
My Carrier: BB Curve

Re: AJAX Problem

[ Edited ]

Ok thanks, now I'm running "E:\Program Files\Research In Motion\BlackBerry WebWorks Packager\mds\run.bat"

but same results, I think I'm missing something else.

 

 

I have also changed the security policy files under C:\Program Files\Java\jre6\lib\security for BBM

 

Thanks