I am creating a Python web service on a Linux machine (ubuntu):
import soaplib
import os
from soaplib.core.service import rpc, DefinitionBase, soap
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array
def runcmd(cmd):
fout = os.popen(cmd)
out = fout.read()
return out
class LinuxServices(DefinitionBase):
@soap(String, String,_returns=Array(String))
def df(self,server, user):
L = []
cmd = 'df -hP | grep "/"'
output = runcmd(cmd).split('\n')
for n in xrange(len(output)-1):
out = output[n].split()
L.append('%s;%s' % (out[5], out[4]))
return L
if __name__=='__main__':
try:
from wsgiref.simple_server import make_server
soap_application = soaplib.core.Application([LinuxServices], 'tns')
wsgi_application = wsgi.Application(soap_application)
server = make_server('0.0.0.0', 7789, wsgi_application)
server.serve_forever()
except ImportError:
print "Error: example server code requires Python >= 2.5"
I created it based on this example: soaplib helloworld
Then (on Windows 7) I created a Silverlight project, where I use this ws to get the status of a drive on my Linux server:
Service in the Silverlight project:
public class LinuxService
{
[OperationContract]
public List<dfItem> df()
{
List<dfItem> dfItems = new List<dfItem>();
WebReference.Application app = new WebReference.Application();
var result = app.df(new WebReference.df());
foreach (var item in result.dfResult)
{
string[] info = item.Split(';');
dfItem dfItem = new dfItem()
{
MountPoint = info[0].ToString(),
Usage = info[1].ToString()
};
dfItems.Add(dfItem);
}
return dfItems;
}
}
Service call on page:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
LinuxServiceClient client = new LinuxServiceClient();
client.dfCompleted += new EventHandler<dfCompletedEventArgs>(client_dfCompleted);
client.dfAsync();
}
void client_dfCompleted(object sender, dfCompletedEventArgs e)
{
DG.ItemsSource = e.Result;
DG.Visibility = System.Windows.Visibility.Visible;
}
My problem is that when I go to this page, it takes 4-8 seconds to get data from ws (ws on the local network).
I really doubt that line bandwidth can create this latency ...
My question is:
Do you have any suggestions on what I can do to speed this up?
System Information: