473,394 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Python XML-RPC Server with clientside Javascript

Hello everyone,

I have used Python SimpleXMLRPCServer to expose several methods to be
used.
My Python script creates a free-standing server and not a CGI script.
I have tested its exposed methods using the following Python script:

import xmlrpclib
s = xmlrpclib.ServerProxy('http://localhost:8765')
print s.my_method()

I tested all methods one by one and they are working as I intended.

Now, I want to use those exposed methods from a static html file
(without any web server) using client side javascript. (i.e. Open
File... from the browser (or file://...) )

I found many XML-RPC examples with javascript but all of them I found
assume XML-RPC services to be deliver from a web server, such as
Apache, as a CGI.

I tried those examples with placing 'http://localhost:8765' as url,
but they didn't work.

How can I utilize the XML-RPC services from a free-standing
SimpleXMLRPCServer in a static HTML page?
Is it possible to do such? Do I need web server to use client-side
javascript?

I have searched the Internet for similar questions. I found similar
postings but there were no clear answers.

Any suggestions will be highly appreciated.
Best regards,
Aki Niimura
Jul 5 '08 #1
2 2623
akineko schrieb:
Hello everyone,

I have used Python SimpleXMLRPCServer to expose several methods to be
used.
My Python script creates a free-standing server and not a CGI script.
I have tested its exposed methods using the following Python script:

import xmlrpclib
s = xmlrpclib.ServerProxy('http://localhost:8765')
print s.my_method()

I tested all methods one by one and they are working as I intended.

Now, I want to use those exposed methods from a static html file
(without any web server) using client side javascript. (i.e. Open
File... from the browser (or file://...) )

I found many XML-RPC examples with javascript but all of them I found
assume XML-RPC services to be deliver from a web server, such as
Apache, as a CGI.
I'd think this has nothing to do with CGI vs. "free-standing", the
client couldn't tell the difference anyway.
It looks like you're running in the "same origin" javascript security
restriction enforced by the browser. That is, the origin of your
javascript is file://... and you're trying to access
http://localhost:8765. This is not allowed.

hth
Paul

Jul 5 '08 #2
Hello Paul,

Thank you very much for your prompt and clear answer.
I didn't know the "same origin" javascript security policy (as I'm not
familiar with javascript).
After reading the description of the "same origin" javascript policy,
I think you are absolutely correct.
The security policy does make sense.
However, if that is the case, it seems I have only two options to make
my project work:
(1) Place my XML-CGI services under a web server so that both HTML
page and RPC services are coming from the same origin
(2) Expand Python DocXMLRPCServer, which renders a HTML page, to
implement my own HTML page from it

I wanted to run the program as a standalone one (no external web
server required).
Therefore, (2) seems the only option I have to make it work.

Anyway, thank you for solving my days-long question.

Best regards,
Aki Niimura

On Jul 5, 3:39 am, paul <p...@subsignal.orgwrote:
>
I'd think this has nothing to do with CGI vs. "free-standing", the
client couldn't tell the difference anyway.
It looks like you're running in the "same origin" javascript security
restriction enforced by the browser. That is, the origin of your
javascript is file://... and you're trying to accesshttp://localhost:8765. This is not allowed.

hth
Paul
Jul 5 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bezeee | last post by:
At my work we are in the process of building a tool to test an XML based API. Basically, XML in and XML out over http. Currently, there are two engines that do all of the schema validations, xml...
8
by: Robert Oschler | last post by:
Has anybody seen a Python module that will take an XML document (not a colossal one), and convert it to a Python nested class object? I'm basically looking for something that would allow me to...
13
by: Ajay | last post by:
hi! can you call a Python application from a Java program? does this require any additional package to be installed? thanks cheers
0
by: PyStarbuck | last post by:
Hi All, Has anybody had an issue with compatiblity between XML files between python 2.3 and python 2.4. I have PyXML 0.8.3 installed in ClearCase and it is shared between Solaris and Windows....
19
by: gaudetteje | last post by:
I've been searching high and low for a way to simply convert a small XML configuration file to Python data structures. I came across gnosis XML tools, but need a built-in option for doing...
5
by: James Owens | last post by:
I anticipate working with XML and XSL a lot over the next few years (I'm in technical documentation). I also happen to be looking for a new scripting language for some CGI interfaces I'll be...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
7
by: fyleow | last post by:
Hi guys, I'm a student/hobbyist programmer interested in creating a web project. It's nothing too complicated, I would like to get data from an RSS feed and store that into a database. I want...
21
by: Raj | last post by:
Hi, We just executed a project with Python using TG. The feedback was to use more python like programming rather than C style code executed in Python. The feedback is from a Python purist and...
2
by: Bruno Rezende | last post by:
Hi, I think I've broken my python installation (don't know how). All the packages that are under 'lib' in python installation doesn't work the way expected: Traceback (most recent call last):...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.