So I started to learn python and I would like to make this little script,
goal is to get wan Ip from my router using UPnP, so I got this code, actualy Im find this code on web and now Im trying to adopt it

Code:
 #!/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()
But it does not corespond to my situation, UPnP service on my router is seted up diferently so I need to make some changes
here is one part of setup configs from IGD.xml from my router in which Im interested in as example

Code:
<service>
    <serviceType>urn:schemas-upnp-org:service:WANPPPConnection:1</serviceType>
    <serviceId>urn:upnp-org:serviceId:WANPPPConn1</serviceId>
    <SCPDURL>/igd_wpc.xml</SCPDURL>
    <controlURL>/upnp/control?WANPPPConnection</controlURL>
    <eventSubURL>/upnp/event?WANPPPConnection</eventSubURL>
    </service>

as u can see diference is in control url in mine case ? is used betwen control and WAN "string" and in code above / is used and heres are mine changes

Code:
import os
    import xml
    from SOAPpy import *

    endpoint = "http://192.168.1.254/upnp/control?WANPPPConnection:1"
    namespace = "urn:schemas-upnp-org:service:WANPPPConnection1"
    soapaction = "urn:upnp-org:serviceId:WANPPPConn1#GetExternalIPAddress"

    server = SOAPProxy(endpoint, namespace)
    print "external IP", server._sa(soapaction).ExternalIPAddress()


but I can not run this at all, and here is error that Im geting

Code: Select all
    Traceback (most recent call last):
      File "UPnP.py", line 11, in <module>
        print "external IP", server._sa(soapaction).ExternalIPAddress()
      File "/usr/lib/pymodules/python2.7/SOAPpy/Client.py", line 470, in __call__
        return self.__r_call(*args, **kw)
      File "/usr/lib/pymodules/python2.7/SOAPpy/Client.py", line 492, in __r_call
        self.__hd, self.__ma)
      File "/usr/lib/pymodules/python2.7/SOAPpy/Client.py", line 406, in __call
        raise p
    SOAPpy.Types.faultType: <Fault s:Client: UPnPError: <SOAPpy.Types.structType detail at 3068858060>: {'UPnPError': <SOAPpy.Types.structType UPnPError at 3068858092>: {'errorCode': '401', 'errorDescription': 'Invalid Action'}}>
Is there any chances thet someone can help me to correct this error tnx