Example #1
0
    def render_POST(self, request):
        data = request.content.getvalue()
        (r, header, body, attrs) = parseSOAPRPC(data, header=1, body=1, attrs=1)

        name = r._name
        kwargs = r._asdict()

        Logr.debug("(%s) %s", self.service.serviceType, name)

        if name not in self.service.actions or name not in self.service.actionFunctions:
            raise NotImplementedError()

        action = self.service.actions[name]
        func = self.service.actionFunctions[name]

        for argument in action:
            if argument.direction == 'in':
                if argument.name in kwargs:
                    value = kwargs[argument.name]
                    del kwargs[argument.name]
                    kwargs[argument.parameterName] = value
                else:
                    raise TypeError()

        result = func(**kwargs)

        return buildSOAP(kw={
            '%sResponse' % name: result
        })
Example #2
0
    def render_POST(self, request):
        data = request.content.getvalue()
        (r, header, body, attrs) = parseSOAPRPC(data, header=1, body=1, attrs=1)

        name = r._name
        kwargs = r._asdict()

        Logr.debug("(%s) %s", self.service.serviceType, name)

        if name not in self.service.actions or name not in self.service.actionFunctions:
            raise NotImplementedError()

        action = self.service.actions[name]
        func = self.service.actionFunctions[name]

        for argument in action:
            if argument.direction == 'in':
                if argument.name in kwargs:
                    value = kwargs[argument.name]
                    del kwargs[argument.name]
                    kwargs[argument.parameterName] = value
                else:
                    raise TypeError()

        result = func(**kwargs)

        return buildSOAP(kw={
            '%sResponse' % name: result
        })
Example #3
0
 def parseSOAP(self, soap):
     '''Parse a SOAP body'''
     soap_body = parseSOAPRPC(soap)
     try:
         count = 0
         for i in soap_body.__dict__.keys():
             if i[0] != "_":  # Don't count the private stuff
                 count += 1
                 soap_value = getattr(soap_body, i)
         if count == 1:  # Only one piece of data, bubble it up
             soap_body = soap_value
     except:
         pass
     return soap_body
Example #4
0
    def render_POST(self, request):
        data = request.content.getvalue()
        (r, header, body, attrs) = parseSOAPRPC(data, header=1, body=1, attrs=1)

        name = r._name
        kwargs = r._asdict()

        Logr.debug("(%s) %s", self.service.serviceType, name)

        if name not in self.service.actions or name not in self.service.actionFunctions:
            raise NotImplementedError()

        action = self.service.actions[name]
        func = self.service.actionFunctions[name]

        for argument in action:
            if argument.direction == 'in':
                if argument.name in kwargs:
                    value = kwargs[argument.name]
                    del kwargs[argument.name]
                    kwargs[argument.parameterName] = value
                else:
                    raise TypeError()

        try:
            result = func(**kwargs)
        except upnpError as e:
            request.setResponseCode(500)
            fault = {'faultcode' : 's:Client', 'faultstring' : 'UPnPError'}
            fault['detail'] = {'UPnPError' : {'errorCode' : e.errorCode, 'errorDescription' : str(e)}}
            return buildSOAP(method='Fault', kw=fault, namespace='http://schemas.xmlsoap.org/soap/envelope/')

        #return buildSOAP(kw={
        #    '%sResponse' % name: result
        #})
        return buildSOAP(method='%sResponse' % name, kw=result, namespace=self.service.serviceType)
Example #5
0
<_1 SOAP-ENC:arrayType="xsd:int[4]" SOAP-ENC:offset="[2]" xsi:type="SOAP-ENC:Array">
    <_2 SOAP-ENC:arrayType="xsd:int[2]" xsi:type="SOAP-ENC:Array">
        <item>1</item>
        <item>2</item>
    </_2>
    <_3 SOAP-ENC:arrayType="xsd:double[2]" xsi:type="SOAP-ENC:Array">
        <item>3.3</item>
        <item>4.4</item>
    </_3>
    <_4 SOAP-ENC:arrayType="xsd:bool[2]" xsi:type="SOAP-ENC:Array">
        <item>0</item>
        <item>1</item>
    </_4> 
    <_5 SOAP-ENC:arrayType="xsd:bool[2]" xsi:type="SOAP-ENC:Array">
        <item>False</item>
        <item>True</item>
    </_5> 
</_1>
</SOAP-ENV:Body>'''

x = parseSOAPRPC(xml)

assert (x[2] == [1, 2])
assert (x[3] == [3.3, 4.4])

# These previously failed, instead having strings
assert (x[4] == [False, True])
assert (x[5] == [False, True])

print "Success"
Example #6
0
xml = env % '''<SOAP-ENV:Body>
<result>
  <_1 SOAP-ENC:arrayType="xsd:double[2]" xsi:type="SOAP-ENC:Array">
    <item>3.3</item>
    <item>4.4</item>
    <item>NaN</item>
    <item>Inf</item>
    <item>+Inf</item>    
    <item>Infinity</item>
    <item>+Infinity</item>        
    <item>-Inf</item>
    <item>-Infinity</item>
  </_1>
</result>
</SOAP-ENV:Body>'''


x = parseSOAPRPC(xml)['_1']

assert( x[0:2] == [ 3.3, 4.4 ] )
assert( fpconst.isNaN(    x[2] ) )
assert( fpconst.isPosInf( x[3] ) )
assert( fpconst.isPosInf( x[4] ) )
assert( fpconst.isPosInf( x[5] ) )
assert( fpconst.isPosInf( x[6] ) )
assert( fpconst.isNegInf( x[7] ) )
assert( fpconst.isNegInf( x[8] ) )

print "Success"

Example #7
0
def SOAPParse(inxml):
    from SOAPpy import parseSOAPRPC
    t = time.time()
    parseSOAPRPC(inxml)
    return time.time() - t
Example #8
0
def SOAPParse(inxml):
    from SOAPpy import parseSOAPRPC
    t=  time.time()
    parseSOAPRPC(inxml)
    return time.time()-t
Example #9
0
        <item>2</item>
    </_2>
    <_3 SOAP-ENC:arrayType="xsd:double[2]" xsi:type="SOAP-ENC:Array">
        <item>3.3</item>
        <item>4.4</item>
    </_3>
    <_4 SOAP-ENC:arrayType="xsd:bool[2]" xsi:type="SOAP-ENC:Array">
        <item>0</item>
        <item>1</item>
    </_4> 
    <_5 SOAP-ENC:arrayType="xsd:bool[2]" xsi:type="SOAP-ENC:Array">
        <item>False</item>
        <item>True</item>
    </_5> 
</_1>
</SOAP-ENV:Body>'''


x = parseSOAPRPC(xml)


assert( x[2] == [ 1, 2 ] )
assert( x[3] == [ 3.3, 4.4 ] )

# These previously failed, instead having strings
assert( x[4] == [ False, True ] )
assert( x[5] == [ False, True ] )

print "Success"