From himanshu.chuphal07 at gmail.com Fri Dec 2 06:23:58 2016 From: himanshu.chuphal07 at gmail.com (Himanshu Chuphal) Date: Fri, 2 Dec 2016 11:53:58 +0530 Subject: [spyne] Spyne: Issue with parsing of attribute with namespace Message-ID: 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 : The problem here is for ns3 we have an element 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:* *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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From burak.arslan at arskom.com.tr Fri Dec 2 07:57:53 2016 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Fri, 2 Dec 2016 10:57:53 +0300 Subject: [spyne] Spyne: Issue with parsing of attribute with namespace In-Reply-To: References: Message-ID: <3e64317e-3d37-9da8-2472-e659e42d94d8@arskom.com.tr> Hello Himanshu, Thanks a lot for your kind words, and also thanks a lot for this very detailed question. On 12/02/16 09:23, Himanshu Chuphal wrote: > 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 I think the thing to do here is simple. Instead of: clientNotificationId = ClientNotificationIdType(Unicode) you should do: clientNotificationId = XmlAttribute(Unicode(sub_ns='http://some_url/notify')) Please let me know whether this works. Best regards, Burak ARSLAN From eric.klumpp at gmail.com Wed Dec 7 11:14:47 2016 From: eric.klumpp at gmail.com (Eric Klumpp) Date: Wed, 7 Dec 2016 12:14:47 +0100 Subject: [spyne] Fwd: how test a web service method with a parameter of any binary type ? In-Reply-To: References: Message-ID: Hi, My problem is detailed in: http://stackoverflow.com/questions/40984811/which- python-soap-client-supports-spyne-binary-types I wonder how binary types are tested in spyne tests. With a soap client like suds ? I would to do the same in my case. So I ask you how I can test my web service method ? I prefer a python solution, but I'm opened to any solution. Eric Klumpp -------------- next part -------------- An HTML attachment was scrubbed... URL: From burak.arslan at arskom.com.tr Thu Dec 8 11:29:34 2016 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Thu, 8 Dec 2016 14:29:34 +0300 Subject: [spyne] Fwd: how test a web service method with a parameter of any binary type ? In-Reply-To: References: Message-ID: <1d3c30b9-bf1c-1d13-ab9a-fcc70d79a2b9@arskom.com.tr> On 12/07/16 14:14, Eric Klumpp wrote: > Hi, > > My problem is detailed in: > http://stackoverflow.com/questions/40984811/which-python-soap-client-supports-spyne-binary-types > > pasting here for completeness: > I want to call a web service method that has a spyne binary type as > argument. > But I'm not able to find any python soap client supporting it. > > To debug my problem, I made a simple web service method that should > print a file: >

>
>     #     @srpc(Attachment, _returns=Unicode)
>         @srpc(ByteArray, _returns=Unicode)
>     #     @srpc(File, _returns=Unicode)
>     #     @srpc(Unicode, _returns=Unicode)
>         def print_file(file_content):
>             logger.info(u"print
> file:\n{}\ntype:{}".format(file_content, file_content.__class__))
>     
>             return u''
>
> 
> > As you can see, I tried with 3 spyne binary types. > For debug, I also tried with Unicode, and passing the file content in > base64, and in this case there is no problem. > Thus the web service is operational. > > The server side is a Django application and a spyne application. > My problem is on client side. > With suds, the obtained error is very obscur, and no solution exists > according forums. > > I tried all SOAP clients described on > https://wiki.python.org/moin/WebServices#SOAP, with python 2.7 and 3.3. > They all fail when building the request, when serializing the spyne > binary object. > > > > My last try is with zeep. > I instantiate the zeep client with wsdl local url. > Sorry, wsdl is not public. > > > > Does anyone know if there is a solution with zeep ? > Perhaps with a dedicated zeep plugin ? > > Or is there another solution ? > Perhaps in C/C++, compiled as a python package ? > First time I heard about zeep. I have no idea, sorry. > I wonder how binary types are tested in spyne tests. > With a soap client like suds ? Just added a test for you: https://github.com/arskom/spyne/commit/be222c041837c9f7cd1e6e6e455e6704b5069837 I'm not aware of any soap client that does binary properly (or at all). Suds does recognize the types but doesn't do encode the data properly. You can make it work by manually doing base64 operations, as can be seen in the test. There are other tests for binary data but they are in the fragment level not protocol level, so I assume not of much interest to you. As for testing Spyne services in general, have a look at NullServer. hth, Burak > I would to do the same in my case. > > So I ask you how I can test my web service method ? > I prefer a python solution, but I'm opened to any solution. > > Eric Klumpp > > > > _______________________________________________ > Spyne community mailing list > people at spyne.io > http://lists.spyne.io/listinfo/people -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric.klumpp at gmail.com Wed Dec 14 16:27:42 2016 From: eric.klumpp at gmail.com (Eric Klumpp) Date: Wed, 14 Dec 2016 17:27:42 +0100 Subject: [spyne] Fwd: how test a web service method with a parameter of any binary type ? In-Reply-To: <1d3c30b9-bf1c-1d13-ab9a-fcc70d79a2b9@arskom.com.tr> References: <1d3c30b9-bf1c-1d13-ab9a-fcc70d79a2b9@arskom.com.tr> Message-ID: Thank you very much. It works. There is a but. Finally, I need also filename. As I know how use ByteArray, I can do my custom ComplexType:


class SFile(ComplexModel):

    filename = Unicode
    data = ByteArray

But the File spyne binary type would be perfect. Is it possible to use suds or another client to manage File type ? As I need to test functionnally my web service, I need a testable solution. Eric 2016-12-08 12:29 GMT+01:00 Burak Arslan : > > > On 12/07/16 14:14, Eric Klumpp wrote: > > Hi, > > My problem is detailed in: > http://stackoverflow.com/questions/40984811/which-python- > soap-client-supports-spyne-binary-types > > > > pasting here for completeness: > > I want to call a web service method that has a spyne binary type as > argument. > But I'm not able to find any python soap client supporting it. > > To debug my problem, I made a simple web service method that should print > a file: >

>
>     #     @srpc(Attachment, _returns=Unicode)
>         @srpc(ByteArray, _returns=Unicode)
>     #     @srpc(File, _returns=Unicode)
>     #     @srpc(Unicode, _returns=Unicode)
>         def print_file(file_content):
>             logger.info(u"print file:\n{}\ntype:{}".format(file_content,
> file_content.__class__))
>
>             return u''
>
> 
> > As you can see, I tried with 3 spyne binary types. > For debug, I also tried with Unicode, and passing the file content in > base64, and in this case there is no problem. > Thus the web service is operational. > > The server side is a Django application and a spyne application. > My problem is on client side. > With suds, the obtained error is very obscur, and no solution exists > according forums. > > I tried all SOAP clients described on https://wiki.python.org/moin/ > WebServices#SOAP, with python 2.7 and 3.3. > They all fail when building the request, when serializing the spyne binary > object. > > > > My last try is with zeep. > I instantiate the zeep client with wsdl local url. > Sorry, wsdl is not public. > > > > Does anyone know if there is a solution with zeep ? > Perhaps with a dedicated zeep plugin ? > > Or is there another solution ? > Perhaps in C/C++, compiled as a python package ? > > > First time I heard about zeep. I have no idea, sorry. > > I wonder how binary types are tested in spyne tests. > With a soap client like suds ? > > > > Just added a test for you: > > https://github.com/arskom/spyne/commit/be222c041837c9f7cd1e6e6e455e67 > 04b5069837 > > I'm not aware of any soap client that does binary properly (or at all). > Suds does recognize the types but doesn't do encode the data properly. You > can make it work by manually doing base64 operations, as can be seen in the > test. > > There are other tests for binary data but they are in the fragment level > not protocol level, so I assume not of much interest to you. > > As for testing Spyne services in general, have a look at NullServer. > > hth, > Burak > > I would to do the same in my case. > > So I ask you how I can test my web service method ? > I prefer a python solution, but I'm opened to any solution. > > Eric Klumpp > > > > _______________________________________________ > Spyne community mailing listpeople at spyne.iohttp://lists.spyne.io/listinfo/people > > > -- Eric Klumpp Davidson Midi-Pyr?n?es Tel: 06 32 66 26 66 -------------- next part -------------- An HTML attachment was scrubbed... URL: From burak.arslan at arskom.com.tr Wed Dec 14 16:43:04 2016 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Wed, 14 Dec 2016 19:43:04 +0300 Subject: [spyne] Fwd: how test a web service method with a parameter of any binary type ? In-Reply-To: References: <1d3c30b9-bf1c-1d13-ab9a-fcc70d79a2b9@arskom.com.tr> Message-ID: <96fb9550-4772-b5c8-fab1-bcad65121814@arskom.com.tr> On 12/14/16 19:27, Eric Klumpp wrote: > Thank you very much. It works. > There is a but. Finally, I need also filename. > > As I know how use ByteArray, I can do my custom ComplexType: >

> class SFile(ComplexModel):
>     filename = Unicode
>     data = ByteArray
> 
> > But the File spyne binary type would be perfect. > Is it possible to use suds or another client to manage File type ? > > As I need to test functionnally my web service, I need a testable > solution. there is File.Value, but it's a Spyne type, not a SOAP standard. The SOAP standard method is MtoM, which has an incomplete implementation somewhere in the Spyne sources. Best, Burak From eric.klumpp at gmail.com Wed Dec 14 17:13:47 2016 From: eric.klumpp at gmail.com (Eric Klumpp) Date: Wed, 14 Dec 2016 18:13:47 +0100 Subject: [spyne] Fwd: how test a web service method with a parameter of any binary type ? In-Reply-To: <96fb9550-4772-b5c8-fab1-bcad65121814@arskom.com.tr> References: <1d3c30b9-bf1c-1d13-ab9a-fcc70d79a2b9@arskom.com.tr> <96fb9550-4772-b5c8-fab1-bcad65121814@arskom.com.tr> Message-ID: Thank you for your help. With the custom type it will work fine. Best, Eric 2016-12-14 17:43 GMT+01:00 Burak Arslan : > > > On 12/14/16 19:27, Eric Klumpp wrote: > > Thank you very much. It works. > > There is a but. Finally, I need also filename. > > > > As I know how use ByteArray, I can do my custom ComplexType: > >

> > class SFile(ComplexModel):
> >     filename = Unicode
> >     data = ByteArray
> > 
> > > > But the File spyne binary type would be perfect. > > Is it possible to use suds or another client to manage File type ? > > > > As I need to test functionnally my web service, I need a testable > > solution. > > > there is File.Value, but it's a Spyne type, not a SOAP standard. The > SOAP standard method is MtoM, which has an incomplete implementation > somewhere in the Spyne sources. > > Best, > Burak > -- Eric Klumpp Davidson Midi-Pyr?n?es Tel: 06 32 66 26 66 -------------- next part -------------- An HTML attachment was scrubbed... URL: