07-21-2011 10:23 AM
07-21-2011 10:30 AM
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("targ etNamespace").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").l ength > 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 ![]()
07-22-2011 03:02 AM
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-Developm
And its also giving "Response not found, connection timeout"
07-22-2011 09:33 AM
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.
button below the post(s)07-25-2011 03:44 AM - edited 07-25-2011 03:46 AM
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