I was testing a web service in PHP and Python. The address of the web service was, let's say, http://my.domain.com/my/webservice
. When I tested the web service in PHP using that URL everything worked fine. But, when I used the same location but in Python using SOAPpy I got an error.
Below is the code I used to communicate with the web service (Python):
from SOAPpy import WSDL
server = SOAPProxy('http://my.domain.com/my/webservice', namespace)
server.myFunction()
The respond I got from the server:
HTTPError: <HTTPError 301 Moved Permanently>
I figure out that if I add a trailing slash to the web service location it works!
from SOAPpy import WSDL
server = SOAPProxy('http://my.domain.com/my/webservice/', namespace)
server.myFunction()
Why the lack of the trailing slash causes the error?
They're different URLs. http://my.domain.com/my/webservice
implies a file webservice
in the my
folder. http://my.domain.com/my/webservice/
implies the default document inside the my/webservice folder.
Many webservers will automatically correct such URLs, but it is not required for them to do so.