Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created June 16, 2011 04:10
Show Gist options
  • Save aaronksaunders/1028659 to your computer and use it in GitHub Desktop.
Save aaronksaunders/1028659 to your computer and use it in GitHub Desktop.
appcelerator soap suds solution Part Two
Titanium.include('suds.js');
var win = Titanium.UI.createWindow({
backgroundColor:'#fff',
fullscreen:true
});
var url='http://extdata.uspta.com/iphonefap/fapwebsvc.asmx';
var callparams = {
zip: '77042',
distance: '5.0'
};
var suds = new SudsClient({
endpoint: url,
targetNamespace :'http://extdata.uspta.com/iphonefap/'
});
try {
suds.invoke('SearchByZipCode', callparams, function(xmlDoc) {
if (xmlDoc.evaluate) {
var result2 = xmlDoc.evaluate("//sp_uspta_SearchZipCode");
var tableData = [];
for (var ii=0; ii < result2.length; ii++) {
var x = result2.item(ii).childNodes;
for (i=0;i<x.length;i++) {
Ti.API.debug("name: " + x.item(i).nodeName +" value: " + x.item(i).text );
}
var row = Ti.UI.createTableViewRow({
height:'100%',
});
var aLabel = Titanium.UI.createLabel({
text: x.item(2).text + " " + x.item(1).text + " miles: " + x.item(10).text,
left:5,
height: 'auto',
width: '100%',
textAlign :'left'
});
row.filter = x.item(2).text + " " + x.item(1).text;
row.add(aLabel);
tableData.push(row);
}
var searchBar = Titanium.UI.createSearchBar({
hintText:'Search',
showCancel:true
});
var tableView = Titanium.UI.createTableView({
data:tableData,
top:0,
width:'100%',
filterAttribute:'filter',
search:searchBar
});
win.add(tableView);
} else {
Ti.API.debug("Error:");
}
});
} catch(e) {
Ti.API.error('Error: ' + e);
}
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment