From abcfilm at gmail.com Sat Dec 13 18:15:48 2014 From: abcfilm at gmail.com (Alex Carr) Date: Sat, 13 Dec 2014 09:15:48 -0800 Subject: [Soap-Python] Custom soap request/response Message-ID: Hello, I'm trying different modules to send SOAP requests to a small Sony Security camera. I'm having trouble formatting the SOAP request, as this wsdl server seems a bit more customized. The proper SOAP request looks like this: Night I'm just having trouble shaping the Output SOAP to match what the server expects. Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: From dieter at handshake.de Sat Dec 27 21:53:48 2014 From: dieter at handshake.de (Dieter Maurer) Date: Sat, 27 Dec 2014 20:53:48 -0000 Subject: [Soap-Python] Suds on Python 2.43 In-Reply-To: References: Message-ID: <21626.6929.311211.811672@localhost.localdomain> Jerry Rocteur wrote at 2014-11-28 15:45 +0100: > ... >I was running on Python 2.7 and it works great there but now I have to >deploy the script on some Redhat workstations running python 2.4.3 >(which I am not allowed to upgrade) > >When I create my client in my script I do it like this: > >url = 'https://system.globalsign.com/cr/ws/GasOrderService?wsdl' >proxy = {'https': proxylog + ":" + proxypass + '@proxyhost.int:9999'} >globalClient = Client(url, proxy=proxy) > > >This works GREAT on 2.7 but when I run it on 2.4 I get: > > File "/usr/lib64/python2.4/urllib2.py", line 580, in proxy_open > if '@' in host: >TypeError: iterable argument required Looks like your "urllib2" is too old for "suds". >I'm Googling it and I can see there are other ways to connect but >can't seem to get the syntax. I do think that a different syntax will help you. Usually, the easiest thing in such situations is to use a sufficiently modern Python version. While you are not allowed to upgrade the system Python, you might be allowed to install a separate modern Python for this task. Likely, you need some so called development packages installed into your Redhat to be able to compile such a private Python version yourself. It might not work, as "https" requires a working "_ssl" which in turn may want a sufficiently modern "OpenSSL" library and if you are unlucky your Redhat might have a too old one - but it is likely worth to try. Perhaps, you are able to convince your administrators to upgrade their Redhat version (and then, maybe, get a modern Python version as a byproduct) - especially, in case the "OpenSSL" library turns out to be too old. This library has seen quite some serious security issues - that's why there are quite frequent important new versions. Sticking to old "OpenSSL" versions can present a significant risk. Upgrading the library regularly is highly advicable. If these approaches are impossible for you, then you likely will need debugging to find out what precisely went wrong where and fix it. Debugging is very powerful but complex, too. Expect that you will need considerable time to learn it. However, once you have done so, it may help you in the future in many occasions. There are IDEs (Integrated Development Environments) which support Python debugging through a GUI (Graphical User Interface). You still need to learn the elementary tools in the debugging toolbox but the GUI assists you with the details. Colleagues of mine have used the commercial (!) WingIDE, there is also a Python plugin for the "Eclipse" IDE (originally for Java/C/C++ development) and "Komodo" (and likely others). If you cannot get an IDE with Python debugging support, you might use Python's "pdb" ("Python DeBugger") module. Its part of the standard Python runtime library. You are not guided by a graphical user interface but must remember the details about the various debugging commands. It might be enough... With a debugger, you will be able to find out what "host" is in the above error situation (I suspect it to be "None" rather than a string). Moving "up" from the error place to the callers (one of the standard debugging commands), you can find out where the wrong "hosts" comes from. Looking at the code, you might be able to find out why it got wrong and how to change things to get it correct. Likely, the place for this change is somewhere in "suds" or "urllib2". If you are unlucky, your administrators will not let you change the code directly where it needs fixing. You might need tricks to get your fix incorporated into your program context. There are essentially two approaches: module shadowing and monkey patches - both potentially dangerous. With "module shadowing", you substitute some (not fully functional) module with one of your own -- in the easiest case via a special "PYTHONPATH" envvar or by inserting your own code directories at the beginning of "sys.path" during startup. With a monkey patch, you modify/replace (not fully functional) functions, methods or classes at runtime (usually during startup) by your own. Let me stress it again. With high likelyhood, the by far most efficient way to get your problem solved it to use a modern Python version - ideally by upgrading the OS version (and get a modern Python as a byproduct) or by a separate modern Python installation specially for your own task. These approaches likely will cost some hours of work (for your administrators and/or you) Analysing in detail what went wrong and how to get it right may have costs in the order of days (rather than hours) -- however, you might get along without support from sometimes reluctant administrators. Ask for help from your project leader to get a decision which approach should be followed. This way, he will at least not be surprised when you take a long time to finish your task. -- Dieter From dieter at handshake.de Sat Dec 27 22:01:27 2014 From: dieter at handshake.de (Dieter Maurer) Date: Sat, 27 Dec 2014 21:01:27 -0000 Subject: [Soap-Python] Soap Newbie GlobalSign SOAP using Suds In-Reply-To: References: Message-ID: <21611.11562.274691.130177@localhost.localdomain> Hallo Jerry, what does "print client" (after client is defined) tells you about the signature of the "GetOrderByOrderId" method? My guess is that the method expects something else as you "tik" and the serialization gets confused as a consequence (but this is a guess only). Jerry Rocteur wrote at 2014-11-17 11:54 +0100: >I'm new to SOAP on Python. > >I need to write some webservice scripts to access Globalsign but I've come >with a silly annoying problem.. > >I chose suds because I thought it was simple and I was able to get going >really quickly.. But.. > >I searched the web for some examples but couldn't really see anything that >helped me. > >I go about it like this; >Python 2.7.3 (default, Feb 21 2013, 16:14:37) >[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2 > > - >>> from suds.client import Client > url = 'https://system.globalsign.com/cr/ws/GasOrderService?wsdl' > proxy = {'https': 'bla bla '} > client = Client(url, proxy=proxy) > >>> tik = client.factory.create('GetOrderByOrderId') > tik.Request.Q>>> tik.Request.QueryRequestHeader.AuthToken.UserName = > "login" > >>> tik.Request.QueryRequestHeader.AuthToken.Password = "password!" > >>> tik.Request.OrderNo = "order" > >>> tik > (GetOrderByOrderId){ > Request = > (GetCrOrderByOrderIdRequest){ > QueryRequestHeader = > (QueryRequestHeader){ > AuthToken = > (AuthToken){ > UserName = "login" > Password = "password" > } > } > OrderNo = "order" > OrderQueryOption = > (OrderQueryOption){ > ReturnCertificateInfo = None > ReturnFulfillment = None > ReturnP7 = None > ReturnModEvents = None > } > } > } > - m = client.service.GetOrderByOrderId(tik) > - > >What it does is create a double and I get a login error, in debug >mode I get this > > >xmlns:ns1="https://system.globalsign.com/cr/ws/" xmlns:xsi=" >http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV=" >http://schemas.xmlsoap.org/soap/envelope/"> > > > >* * >* * > > > login > password > > > order6 >* * >* * > > > > >When I manually remove the extra and paste into SOAPUI it works >correctly. > >Does anyone know of a better what to go about this ? > >Can anyone see what I'm doing wrong above that it creates the two Requests ? > >Thanks in advance. > > >-- >Jerry Rocteur > >j >erry.rocteur at gmail.com -- Dieter From dieter at handshake.de Sat Dec 27 23:33:50 2014 From: dieter at handshake.de (Dieter Maurer) Date: Sat, 27 Dec 2014 22:33:50 -0000 Subject: [Soap-Python] suds: attribute of complex argument does not get namespace prefix In-Reply-To: References: Message-ID: <21402.58917.792704.152604@localhost.localdomain> 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 dieter at handshake.de Sun Dec 28 00:12:09 2014 From: dieter at handshake.de (Dieter Maurer) Date: Sat, 27 Dec 2014 23:12:09 -0000 Subject: [Soap-Python] WSSE In-Reply-To: <5087369cbc019085f1b8194fcd75466f.squirrel@squirrel.asgardian.be> References: <5087369cbc019085f1b8194fcd75466f.squirrel@squirrel.asgardian.be> Message-ID: <21238.32722.897586.568345@localhost.localdomain> Thierry Leurent wrote at 2013-11-22 08:20 +0100: >I must read a SOAP request, add a WS-Security hearder and send it. >I search in Internet, I found informations about some framework like PyXB >but never a complete documentation. > >I try to understand the PyXB code, but I'm not a expert in Python and in >SOAP, and I don't understand the code. "PyXB" does not provide you with WSSE. Its main functionalities: * generate Python classes corresponding to the types defined in an XML-Schema * provide a parser for instances of the XML-Schema (refered to above) which parse those instances into Python objects (instances of the classes generated above) * the instances of the generated classes have a method to serialize them as instances of the XML-Schema. To state it differently: starting with an XML-Schema, "PyXB" generates Python classes and provides a bedirectional mapping between the corresponding XML documents and Python objects. WSSE has an associated XML-schema (in fact a set of interacting schemas) - and "PyXB" comes out of the box with the corresponding Python classes. This way, you can "do" WSSE by means of Python objects rather than directly XML documents (or fragments thereof). This may help quite a bit: you do not need to an XML expert. However, you still need to know WSSE (at a more abstract level): you must know which objects are involved, what attributes they have and how to compute senseful values for them. >Where can I find samples, doc and any informartions about PyXB, an other >framework or another way to develop a solution ? PyXB is very well documented -- when you visit "PyXB" on "pypi" ("https://pypi.python.org/pypi/PyXB/1.2.3"), you see quite prominently a link "Package Documentation". This link brings you to the "PyXB" documentation. However, it will not tell you how to do WSSE with "PyXB". It tells you how to use "PyXB" for its primary functionality (see above). I do not know "WSSE" well (therefore, I cannot help you with your concrete problem). However, I have used "PyXB" to do something similar for "SAML2". In my case "PyXB" does the mapping between Python and XML for me. However, I must know "SAML2" well and I must know XML-DSig (XML based digital signatures) (I use "dm.xmlsec.binding" (based on "libxmlsec", the XML security library) to handle the signatures). I expect that for "WSSE" the case will be similar (if you do not find an out-of-the-box "WSSE" solution but implement it yourself on top of "PyXB"). -- Dieter From dieter at handshake.de Sun Dec 28 00:14:33 2014 From: dieter at handshake.de (Dieter Maurer) Date: Sat, 27 Dec 2014 23:14:33 -0000 Subject: [Soap-Python] suds without internet access[help] In-Reply-To: References: Message-ID: <21381.47237.422391.586083@localhost.localdomain> Lupin Deterd wrote at 2014-5-28 16:56 +1200: > I'm using suds for accessing SOAP server but it's failling. Same with >this issue unfortunately the suggested work-around isn't working. suds >failed without internet >access > >The problem with suds is that it tries to download from the internet >XMLSchema.xsd without success: > >DEBUG:suds.xsd.sxbasic:Import:0xb7808a6cL, importing >ns="http://www.w3.org/2001/XMLSchema", >location="http://www.w3.org/2001/XMLSchema.xsd" >DEBUG:suds.transport.http:opening >(http://www.w3.org/2001/XMLSchema.xsd)Traceback (most recent call >last):..... >urllib2.URLError: > > >I am not a full time developer, so my question are: > >-> Why does a library like that need to reference an online link? Because the WSDL you are (indirectly) using explicitely imports this schema (there is no need to do this). >-> Is there any work-around for this that will work without this suds >client access to internet? If you have control over the WSDL (and the schema referenced therein), the easiest thing would be to remove the "XMLSchema" "import" (you must define the namespace but there is no need to import the actual definitions). If you cannot do this, "suds" has some support to handle broken WSDLs - look at the "suds" documentation; when I remember right there is a section "how to handle broken WSDL" (or something like that).