<SCPDURL>/WANPPPConnection.xml</SCPDURL>
</service>
For sending SOAP requests only controlURL is necessary. The eventSubURL is used
in the next step. Which actions can be performed depends on the profile. The URL
found at SCPDURL is the so called “URL for service description” and it describes
which SOAP requests can be performed and what the so-called state variables are.
SOAP is a protocol that runs over HTTP and uses XML to describe “function
calls” to a server and return results from those calls. SOAP is mainly used to
make use of web based services. For every major programming language libraries
are available that can be used to implement SOAP requests and process SOAP
responses. Throughout this paper there are various Python code snippets. The
SOAP library that is used is SOAPpy[3].
One of the actions that can be performed on a control point that implements the
WANPPPConnection profile is GetExternalIPAddress, which is used to get the ex-
ternal IP address of the device:
#!/usr/bin/python
import os
from SOAPpy import *
## "endpoint" is the control URL for WANPPPConnection on a Speedtouch 510
endpoint = "http://10.0.0.138/upnp/control/wanpppcpppoa"
namespace = "urn:schemas-upnp-org:service:WANPPPConnection:1"
soapaction = "urn:schemas-upnp-org:service:WANPPPConnection:1#GetExternalIPAddress"
server = SOAPProxy(endpoint, namespace)
print "external IP", server._sa(soapaction).GetExternalIPAddress()
Adding a port mapping for the machine located at the IP address 10.0.0.151 can
be done with the following code:
soapaction2 = "urn:schemas-upnp-org:service:WANPPPConnection:1#AddPortMapping"
server._sa(soapaction2).AddPortMapping(NewRemoteHost="",
NewExternalPort=8080,
NewProtocol="TCP",
NewInternalPort=80,
NewInternalClient="10.0.0.151",
NewEnabled=1,
NewPortMappingDescription="internal webserver",
NewLeaseDuration=0)
A portmapping can be deleted with a similar SOAP action:
soapaction3 = "urn:schemas-upnp-org:service:WANPPPConnection:1#DeletePortMapping"
server._sa(soapaction3).DeletePortMapping(NewRemoteHost="",
NewExternalPort=5666,
NewProtocol="TCP")
Comentários a estes Manuais