From burak.arslan at arskom.com.tr Sun Jun 1 16:06:40 2014 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Sun, 01 Jun 2014 17:06:40 +0300 Subject: [Soap-Python] Spyne and suds on Python 3 Message-ID: <538B3370.30300@arskom.com.tr> Hello, I'm happy to let you know that I've just made suds-jurko and Spyne work on Python 3, save for one test that involves last_received(). https://spyne.ci.cloudbees.com/job/spyne/PYFLAV=3.3/lastCompletedBuild/testReport/spyne.test.interop.test_suds/TestSuds/test_send_out_complex_header/ The last couple of commits fixed a whopping 98 tests at once :) https://spyne.ci.cloudbees.com/job/spyne/PYFLAV=3.3/ Best regards, Burak From fabien.leboeuf at gmail.com Wed Jun 4 11:46:56 2014 From: fabien.leboeuf at gmail.com (fabien leboeuf) Date: Wed, 4 Jun 2014 11:46:56 +0200 Subject: [Soap-Python] python simplexml Message-ID: Hi I wish use tour python library for - reading a xml file - get a xml node and modify it i think your library is adapted but where i can find example, especially for reading an xml file regards Fabien -- Fabien Leboeuf ------------------------------------------------------------------------------------------------ - Ing?nieur de recherche au CHU de Nantes - Docteur en m?canique-Biom?canique de l'Universit? de Poitiers ------------------------------------------------------------------------------------------------ P?le M?decine Physique et R?adaptation H?pital St Jacques 85 rue saint Jacques 44 093 Nantes cedex1 -*-*-*-*-*-*-*-*-*-*-*-*-*-*-* T?l : 02 40 84 60 88 * Port: 06 07 79 02 44 * ------------------------------------------------------------------------------------------------ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ralienpp at gmail.com Thu Jun 5 10:15:36 2014 From: ralienpp at gmail.com (Alex) Date: Thu, 5 Jun 2014 11:15:36 +0300 Subject: [Soap-Python] python simplexml In-Reply-To: References: Message-ID: Hi, If you need to process an XML file, then you don't need a SOAP/XML library, you need an XML library. You could give a try to lxml, which is well documented: http://lxml.de/parsing.html Here's an "off the top of my head" example: from lxml import etree rawData = open('file.xml', 'rb').read() doc = etree.fromstring(rawData) You can then interact with `doc` as follows: print doc[0] #assuming that such an element exist print doc[0].text doc[0].text = 'new value' `doc.tostring()` will return a string that corresponds to the changed XML data. You might want to learn XPath too, which is a convenient way to find and extract information out of an XML file, and manipulate it in other ways. Some time ago I made a screencast where lxml is used, along with XPath queries: https://www.youtube.com/watch?v=PgWfF-Ut0zM Note that in the screencast I am using lxml's XPath functionality to find data in a web-page, not from an XML file, but the principle is the same. Good luck, Alex From reingart at gmail.com Thu Jun 5 18:37:24 2014 From: reingart at gmail.com (Mariano Reingart) Date: Thu, 5 Jun 2014 13:37:24 -0300 Subject: [Soap-Python] python simplexml In-Reply-To: References: Message-ID: 2014-06-04 6:46 GMT-03:00 fabien leboeuf : > Hi > > I wish use tour python library for > - reading a xml file > - get a xml node and modify it > > If you're refereing to SimpleXmlElement (in simplexml.py, inspired by the PHP extension and based on xml.dom.minidom), the documentation is at: https://code.google.com/p/pysimplesoap/wiki/SimpleXmlElement i think your library is adapted but where i can find example, especially > for reading an xml file > > To create a simple xml element object based on the file contents do: >>> from pysimplesoap.simplexml import SimpleXMLElement >>> f = open("yourfile.xml") >>> xml = SimpleXMLElement(f.read()) >>> print repr(xml) testpassword To get a tag: >>> xml("username") test TO add a tag: >>> xml("MyTestHeader").add_child("foo", "bar") bar >>> print repr(xml) testpasswordbar You can also use import_node method to add a complete SimpleXMLElement inside a tag. Best regards Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From esiotrot at gmail.com Thu Jun 12 10:50:06 2014 From: esiotrot at gmail.com (Michael Wood) Date: Thu, 12 Jun 2014 10:50:06 +0200 Subject: [Soap-Python] trouble calling service (pysimplesoap) In-Reply-To: <007b01cf26c0$aa71ba30$ff552e90$@infinitiv.com> References: <007b01cf26c0$aa71ba30$ff552e90$@infinitiv.com> Message-ID: On 11 February 2014 02:31, Scobie Smith wrote: > Hi, > > > > I?m relatively new to Python and certainly new to consuming web services > via Python. > > I have a WCF (.NET) service (SOAP), which I am trying to call from Python. > > I?ve tried osa, but that failed to parse the wsdl successfully. (I?m not > sure what the easiest/best library is....) > > Now I?m using pysimplesoap, but I get the following error. > > My service has a no-op method, for testing purposes: void NoOp(). In other > words, the service method does absolutely nothing and returns nothing. This > is just to test that pysimplesoap can successfully call the method. Here is > my python code: > > > > from pysimplesoap.client import SoapClient > > > > wsdl_url = ' > http://localhost:8733/Design_Time_Addresses/LexemeRepositoryServiceLibrary/LexemeRepositoryService/?wsdl > ' > > > > client = SoapClient(wsdl=wsdl_url) > > > > s = client.NoOp() > > > > print(s) > > > > The code fails on the call to NoOp() with the following output: > > > > Traceback (most recent call last): > > File "lexsoap.py", line 8, in > > s = client.NoOp() > > File > "C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\client.py", > line 141, in > > File > "C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\client.py", > line 285, in wsdl_call > > File > "C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\client.py", > line 207, in call > > File > "C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\client.py", > line 236, in send > > File > "C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\transport.py", > line 125, in request > > UnboundLocalError: local variable 'f' referenced before assignment > > > > Since my code does nothing, this looks like a problem within pysimplesoap. > > When I examine transport.py, the request function is this: > > > > def request(self, url, method="GET", body=None, headers={}): > > req = urllib2.Request(url, body, headers) > > try: > > f = self.request_opener(req, timeout=self._timeout) > > except urllib2.HTTPError as f: > > if f.code != 500: > > raise > > return f.info(), f.read() > Looks like a bug. You might get a more useful error by changing it to: def request(self, url, method="GET", body=None, headers={}): req = urllib2.Request(url, body, headers) f = None try: f = self.request_opener(req, timeout=self._timeout) except urllib2.HTTPError as f: if f is None or f.code != 500: raise return f.info(), f.read() -- Michael Wood -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomas.hottendorff at hvbo4.de Thu Jun 12 15:31:26 2014 From: thomas.hottendorff at hvbo4.de (Thomas Hottendorff) Date: Thu, 12 Jun 2014 13:31:26 +0000 (UTC) Subject: [Soap-Python] suds: attribute of complex argument does not get namespace prefix Message-ID: 0 down vote favorite I'm trying to write a saop client to connect to the mks integrity soap interface using python 2.7.3 and suds-jurko 0.6 (or suds-03.9). However I'm stuck now with my first example because the attributes transactionId and ItemId that belong to the complex argument I pass on with the method lack the required namespace prefixes (ns1:...) in my example. So, my question is, is there a means to add these? Here's the code I have: #!/usr/bin/env python # # import logging import suds from suds.client import Client # Send log messages to console logging.basicConfig(level=logging.INFO) # Set Suds logging level to debug, outputs the SOAP messages. logging.getLogger('suds.client').setLevel(logging.DEBUG) # Web service url = "http://besrv-mks01.ta.global:7001/webservices/2009/Integrity/?wsdl" headers = dict( SOAPAction = 'action' ) client = Client(url, headers = headers) print client getItemType = client.factory.create('ns5:GetItemType') getItemType.Username = "some_user" getItemType.Password = "secret" getItemType.InputField = [ "Story Elaboration Notes" ] getItemType._ItemId = "1554094" getItemType._transactionId = "?" print getItemType try: result = client.service.getItem(getItemType) except suds.WebFault, e: print e This produces the following output: --snip (GetItemType){ Username = "some_user" Password = "secret" ImpersonatedUser = None DateFormat = None DateTimeFormat = None _transactionId = "?" InputField[] = "Story Elaboration Notes", _ItemId = "1554094" } DEBUG:suds.client:sending to (http://besrv-mks01.ta.global:7001/webservices/2009/Integrity/) message: <== attributes here! some_user secret Story Elaboration Notes DEBUG:suds.client:headers = {'SOAPAction': 'action', 'Content-Type': 'text/xml; charset=utf-8'} DEBUG:suds.client:HTTP failed - 500 - Internal Server Error: env:ServerUnable to retrieve item null. ERROR:suds.client: Server raised fault: 'Unable to retrieve item null.' When I manually add the namespace prefix to the attributes and submit the request via curl, I get the expected response. From costea.bostan.work at gmail.com Thu Jun 12 16:48:53 2014 From: costea.bostan.work at gmail.com (Bostan Constantin) Date: Thu, 12 Jun 2014 17:48:53 +0300 Subject: [Soap-Python] Questions about SSL certificate authentication Message-ID: Hi, I'm developing a system in python that uses suds with requests library to connect to a server over https with a given certificate in .pem format. I had noticed that server respond to my connection with: "400 The SSL certificate error" although if I connect to the server using an installed locally .pfx certificate it connects without any errors. The .pem file used in the system was obtained from that working .pfx file using openssl command line: "openssl pkcs12 -in certificate.pfx -out certificate.pem -nodes". I had tried to connect using another library: urllib2 and still the same problem. When I verify my generated .pem file using "openssl verify certificate.pem" I'm obtaining the following error: "error 20 at 0 depth lookup:unable to get local issuer certificate". Therefore my questions are: Maybe I'm using the wrong library or certificate format to connect to the server. Does anyone have a demo code or a certificate example? And how to solve this bug: "error 20 at 0 depth lookup:unable to get local issuer certificate", is there a command line to solve this certificate bug ? Have a nice day. -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomas.hottendorff at hvbo4.de Fri Jun 13 16:41:50 2014 From: thomas.hottendorff at hvbo4.de (thomas.hottendorff at hvbo4.de) Date: Fri, 13 Jun 2014 16:41:50 +0200 Subject: [Soap-Python] suds: attribute of complex argument does not get namespace prefix In-Reply-To: <21402.58917.792704.152604@localhost.localdomain> References: <21402.58917.792704.152604@localhost.localdomain> Message-ID: <20140613164150.Horde.VMSj3_QrlRNh7O6AqihgNw1@webmail.your-server.de> When I look at the schema, i find: So, the attribute ItemId needs to be qualified with the namespace. It seems that suds does *not* obey the form="qualified" instruction :-( I guess I will have to file a bug on this. Thanks for pointing this out and the link. Very instructive. Thomas Quoting Dieter Maurer : > Thomas Hottendorff wrote at 2014-6-12 13:31 +0000: >> ... >> However I'm stuck now with my first example because the attributes >> transactionId and ItemId that belong to the complex argument I pass on with >> the method lack the required namespace prefixes (ns1:...) in my example. So, >> my question is, is there a means to add these? > > It is rare that attributes require qualification. > Whether they do is controlled by a schema attribute > ("attributeFormDefault='qualified'"); the default is "unqualified" > (no prefixes). > > Thus, check whether your schema correctly calls for > qualified attributes. If it does, you may have hit a "suds" bug > (maybe undetected for a long time as qualified attributes are rare). > > > You can read more about "attributeFormDefault" at > "http://www.intertech.com/Blog/xml-schema-elementformdefault-and-attributeformdefault/". > > > > -- > Dieter From vsza at vsza.hu Sat Jun 14 11:15:40 2014 From: vsza at vsza.hu (Veres-Szentkiralyi Andras) Date: Sat, 14 Jun 2014 11:15:40 +0200 Subject: [Soap-Python] Questions about SSL certificate authentication In-Reply-To: References: Message-ID: <20140614091540.GA4144@kettohusz> The first thing I'd do would be sniffing the network traffic with Wireshark or tcpdump and look for differences between using the .pfx and the .pem file. Even though we're speaking of an encrypted connecton, the negotiation happens in plain, so you should be able to spot the problem. Two things that might cause the problem: - missing SNI (look for it in the Client Hello packet, Python 2 unfortunately has no support for it, and maybe the server expects is) - using the PEM for server certificate verification, not as a client certificate Could you post a short example on how you tried it with requests? Do the PEM file contain both a PRIVATE KEY and a CERTIFICATE part? Cheers, Andr?s Veres-Szentkir?lyi On Thu, Jun 12, 2014 at 05:48:53PM +0300, Bostan Constantin wrote: > Hi, I'm developing a system in python that uses suds with requests library > to connect to a server over https with a given certificate in .pem format. > I had noticed that server respond to my connection with: "400 The SSL > certificate error" although if I connect to the server using an installed > locally .pfx certificate it connects without any errors. The .pem file > used in the system was obtained from that working .pfx file using openssl > command line: "openssl pkcs12 -in certificate.pfx -out certificate.pem > -nodes". I had tried to connect using another library: urllib2 and still > the same problem. When I verify my generated .pem file using "openssl > verify certificate.pem" I'm obtaining the following error: "error 20 at 0 > depth lookup:unable to get local issuer certificate". Therefore my > questions are: > > Maybe I'm using the wrong library or certificate format to connect to the > server. Does anyone have a demo code or a certificate example? And how to > solve this bug: "error 20 at 0 depth lookup:unable to get local issuer > certificate", is there a command line to solve this certificate bug ? > > Have a nice day. From costea.bostan.work at gmail.com Mon Jun 16 10:56:55 2014 From: costea.bostan.work at gmail.com (Bostan Constantin) Date: Mon, 16 Jun 2014 11:56:55 +0300 Subject: [Soap-Python] Questions about SSL certificate authentication In-Reply-To: <20140614091540.GA4144@kettohusz> References: <20140614091540.GA4144@kettohusz> Message-ID: Hi, thanks for the answer, I solved the issue, the problem was in pem certificate not in requests library, it didn't had all the necessary keychain certificates (thats what this error was about: "error 20 at 0 depth lookup:unable to get local issuer certificate"). After adding all the necessary certificates I was able to connect to the server. On 14 June 2014 12:15, Veres-Szentkiralyi Andras wrote: > The first thing I'd do would be sniffing the network traffic with > Wireshark or tcpdump and look for differences between using the .pfx and > the .pem file. Even though we're speaking of an encrypted connecton, the > negotiation happens in plain, so you should be able to spot the problem. > > Two things that might cause the problem: > - missing SNI (look for it in the Client Hello packet, Python 2 > unfortunately has no support for it, and maybe the server expects is) > - using the PEM for server certificate verification, not as a client > certificate > > Could you post a short example on how you tried it with requests? > Do the PEM file contain both a PRIVATE KEY and a CERTIFICATE part? > > Cheers, > Andr?s Veres-Szentkir?lyi > > On Thu, Jun 12, 2014 at 05:48:53PM +0300, Bostan Constantin wrote: > > Hi, I'm developing a system in python that uses suds with requests > library > > to connect to a server over https with a given certificate in .pem > format. > > I had noticed that server respond to my connection with: "400 The SSL > > certificate error" although if I connect to the server using an installed > > locally .pfx certificate it connects without any errors. The .pem file > > used in the system was obtained from that working .pfx file using openssl > > command line: "openssl pkcs12 -in certificate.pfx -out certificate.pem > > -nodes". I had tried to connect using another library: urllib2 and still > > the same problem. When I verify my generated .pem file using "openssl > > verify certificate.pem" I'm obtaining the following error: "error 20 at 0 > > depth lookup:unable to get local issuer certificate". Therefore my > > questions are: > > > > Maybe I'm using the wrong library or certificate format to connect to the > > server. Does anyone have a demo code or a certificate example? And how to > > solve this bug: "error 20 at 0 depth lookup:unable to get local issuer > > certificate", is there a command line to solve this certificate bug ? > > > > Have a nice day. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From barcklay at gmail.com Thu Jun 19 02:40:29 2014 From: barcklay at gmail.com (Robert Barcklay) Date: Wed, 18 Jun 2014 17:40:29 -0700 Subject: [Soap-Python] Generating simple XML elements with attributes from Spyne Message-ID: I am trying to generate an XML element for a SOAP header using Spyne 2.10.10 that looks like this: MyAction I cannot figure out how to define my Class in Spyne get this output when the response is generated. I?ve tried many approaches for both defining the class and then setting the values. Can it be done with a subclass of Unicode? class Action(Unicode): must_understand = XMLAttribute(Unicode) This doesn?t seem to work. When I use ComplexModel as the superclass, I get an element name of ?string? which is not right. class Action (ComplexModel): __type_name__ = "Action" __namespace__ = NAMESPACE_ADDRESSING data = XmlData(Unicode) must_understand = XmlAttribute(Unicode) ? Action.__call__(data =?myAction?, must_understand="1?) Results (in bold): MyAction > > I cannot figure out how to define my Class in Spyne get this output > when the response is generated. I've tried many approaches for both > defining the class and then setting the values. > > Can it be done with a subclass of Unicode? > > class Action(Unicode): > must_understand = XMLAttribute(Unicode) > > > > This doesn't seem to work. it won't. > > When I use ComplexModel as the superclass, I get an element name of > 'string' which is not right. > > class Action (ComplexModel): > __type_name__ = "Action" > __namespace__ = NAMESPACE_ADDRESSING > data = XmlData(Unicode) > must_understand = XmlAttribute(Unicode) > ... > > Action.__call__(data ='myAction', must_understand="1") > > > > Results (in bold): > > > * myAction* > ... > > > > > Why is this coming out as 'string' and not 'Action' ? How can I put a > different namespace in front of 'must_understand'? class Action (ComplexModel): class Attributes(ComplexModel.Attributes): sub_ns = "SOME_NS" sub_name = "Action" data = XmlData(Unicode) must_understand = XmlAttribute(Unicode) see: https://github.com/arskom/spyne/blob/d0f7cc4167c6ccef0390dc5095c23112f14a5254/spyne/test/protocol/test_xml.py#L674 > > Any suggestions greatly appreciated. There is an open Stackoverflow > question on this topic: > > http://stackoverflow.com/questions/22016045/setting-xml-element-text-nodes-in-spyne > I answered it, but that's not the same case as your issue. There was a bug about your case which prevented sub_ns and sub_name working when the class at hand is not serialized as a child of a ComplexModel subclass. I hope this helps. Best, Burak -------------- next part -------------- An HTML attachment was scrubbed... URL: From burak.arslan at arskom.com.tr Mon Jun 30 14:41:47 2014 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Mon, 30 Jun 2014 15:41:47 +0300 Subject: [Soap-Python] Spyne 2.11.0 is released Message-ID: <53B15B0B.50608@arskom.com.tr> Dear All, I'm very happy to let you know that 2.11 was released oh 24th of June. As you may know, this is a huge release with ~1400 commits spanning more than a year of hard work. Many thanks to all who have contributed with patches, docs, issue reports, kind words and other help. I don't think I have to name names, but we all know that this release would not have been as awesome without you. The soap-related novelties are: 1) An Xml parser, which is a giant step towards having a full-blown wsdl parser. This means that eventually a soap client will be implemented in Spyne. Any testing / help with these new functionality is quite welcome. 2) XmlData -- the way to add simpleContent nodes. 3) Attribute_of is now deprecated. Use a complex model with an XmlData enclosing a primitive. Here's an example: http://stackoverflow.com/questions/22016045/setting-xml-element-text-nodes-in-spyne While I'll continue producing and reviewing patches as usual, for the coming weeks I'll mainly focus on revamping the documentation. I'm not so much in a hurry because 2.10 docs also fully apply to 2.11 release. I hate to leave broken links behind, so instead i chose to leave it all out until I revise it all. After all, it's been a year since I last looked at these Make sure you read the migration guide: http://spyne.io/docs/2.11/migration.html#migration-210-211 There shouldn't be much to do besides a couple of tweaks here and there. Please do not hesitate to get in touch if you run into issues with 2.10 => 2.11 migration. I hope you find Spyne 2.11.0 useful. Best regards, Burak