Hi Sypne Dev,

thanks for providing this amazing spyne lib.
I have got the subscription to http://lists.spyne.io/subscribe/people

I was using the lib for one of my tasks wherein I'm trying to parse a soap
envelope request having multiple namespaces including an attribute with the
namespace.

See below xml soap envelope request :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
   <soapenv:Body>
       <ns3:StatusNotification xmlns:ns3="http://some_url/notify";
*ns3:clientNotificationId="87654321"*>
           <ns3:status type="STARTED"
timestamp="2016-11-13T17:11:49.195+03:00" *ns3:executionId*="117336">
       </ns3:status>
   </ns3:StatusNotification>
   </soapenv:Body>
</soapenv:Envelope>



The problem here is for ns3 we have an element  <status> which has 3
attributes ( type, timestamp and *executionId) but the issue is in the xml
I am using has "**executionId" with prefix as "ns3:" ( **ns3:executionId*
="117336")

Likewise spyne is not able to identify  *ns3:clientNotificationId="87654321"
because of the same prefix "ns3:".*



*I have used below code to parse it using sypne lib :*

class  NotificationType(ComplexModel):
    __namespace__ = 'http://some_url/notify'
    __metaclass__ = ComplexModelMeta

class GetStatusType(NotificationType):
    executionId = XmlAttribute(Integer)
    timestamp = XmlAttribute(DateTime)
    type = XmlAttribute(String(values=('CREATED', 'STARTED',
'INTERRUPTING', 'INTERRUPTED', 'FINISHED', 'FAILED')),
                        use='required')

class GetclientNotificationId(NotificationType):
    __type_name__ = 'StatusNotification'

class ClientNotificationIdType(XmlAttribute):
   __namespace__ = 'http://some_url/notify'

class GetStatusNotification(NotificationType):
    clientNotificationId = ClientNotificationIdType(Unicode)
    status = GetStatusType


class GetFeedbackNotification(NotificationType):
    clientNotificationId = XmlAttribute(Unicode)

______________________________________________

*spyne app:*

    app = Flask(__name__)
    nbi_spyne = Spyne(app)

    from spyne.model.primitive import Unicode, Integer
    from spyne.model.complex import Iterable

    class NBIService(nbi_spyne.Service):
        __service_url_path__ = '/test'
        __in_protocol__ = Soap11(validator='lxml')
        __in_protocol__ = Soap11()
        __out_protocol__ = Soap11()
        __target_namespace__ = 'http://some_url/notify'
        __wsdl_access__ = 'allow'  # 'no_access' to restrict the access of
wsdl and 'allow' to grant the access


        @nbi_spyne.rpc(GetStatusNotification, _returns=Integer,
                       _soap_body_style='rpc', _body_style='bare')
        def StatusNotification(context, request):
            logger.info("StatusNotification received with Status
{}".format(request))
            response = 200
            return response


_______________________________________________


*using this I expect below schema:*


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:not="
http://www.nsn.com/schemas/public/cm/open-api/operations/notification";>
   <soapenv:Header/>
   <soapenv:Body>
      <not:StatusNotification clientNotificationId="?">
         <!--Optional:-->
         <not:status timestamp="?" executionId="?" type="?"/>
      </not:StatusNotification>
   </soapenv:Body>
</soapenv:Envelope>

*which doesn't include the prefix "ns3:".*

*If I remove the prefix "ns3:" from the attributes, my code works perfectly
and I get the attributes as expected.*

Please let me know is there any way to parse the attributes having
namespaces as prefix ( "ns3:" as here) or is it feasible to modify
handle_rpc parsing for such soap envelope requests


Looking forward for some valuable inputs from your side.


thanks
Himanshu
+91-9990941983
_______________________________________________
Spyne community mailing list
people@spyne.io
http://lists.spyne.io/listinfo/people

Reply via email to