Patch of soaplib in Python For .Net Invoke
March 2nd, 2010 by skysbird
On Sat, Aug 29, 2009 at 10:33 AM, Maksymus007<maksymus...@gmail.com> wrote: > On Sat, Aug 29, 2009 at 5:40 AM, Wombatpm<bruce.brombe...@gmail.com> wrote: >> >> For the record. SOAPLIB 0.8.1 has a bug in generating the WSDL file >> for Arrays. >> >>> <xs:complexType name="stringArray"> >>> - >>> <xs:sequence> >>> <xs:element minOccurs="0" maxOccurs="unbounded" type="tns:string" >>> name="string"/> >>> </xs:sequence> >>> </xs:complexType> >> >> the type declaration should be type="xs:string" >> >> >> The unicode issue is being raised by lxml inside of soaplib. Calls >> from .NET clients include an xml declaration and an encoding type. >> Calls from SOAPUI do not include the xml declaration. Under python >> 2.6 strings are unicode so lxml raises the error. >> >> Question to django world: Where is the best place to fix this bug? >> lxml where they punted on unicode strings effectively? Soaplib which >> should sanitize its calls? or Django since it knows what it received >> over the intertubes and is in the best position to create the string >> correctly? >> >> WombatPM >> > > I was debugging till 3am yesterday to fix this, but not everything works now. > I fixed this unicode bug (but didn't test this with real unicode chars) > Generating arrays is another strange thing, 'cause my simple service > does not use it. > Hope today or tomorrow I fix it and then will post patch here and to > soaplib developers > OK, so mi fixes are simple. Open serializers/primitive.py and change line 445 to "%s:%s" % (self.serializer.get_namespace_id(), self.serializer.get_datatype())) and soaplib/soap.py line 118 to root, xmlids = ElementTree.XMLID(xml_string.encode()) and this makes by services and WSDL files working both in SoapUI and standard PHP SOAP without any problems (remember to name parameters in PHP) by the way, We also need to modify the proxy generated by .net.(References.cs), We should remove the Namespace on the Response type. Otherwise we will get null in every invoke. And more, we should look some output response ,and remove the code in proxy code(Reference.cs) <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns="archweb.views.Service"><SOAP-ENV:Body><get_sub_departResponse><get_sub_departResult type="tns:WsTreeArray"><WsTree><deptid xsi:type="xs:string">00882</deptid><src_desc xsi:type="xs:string">B2B</src_desc><pid xsi:type="xs:int">0</pid><desc xsi:type="xs:string">B2B</desc></WsTree><WsTree><deptid xsi:type="xs:string">00002</deptid><src_desc xsi:type="xs:string">CFO</src_desc><pid xsi:type="xs:int">0</pid><desc xsi:type="xs:string">CFO</desc></WsTree><WsTree><deptid xsi:type="xs:string">00529</deptid><src_desc xsi:type="xs:string">顾问</src_desc><pid xsi:type="xs:int">0</pid><desc xsi:type="xs:string">顾问</desc></WsTree></get_sub_departResult></get_sub_departResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> we should remove the get_sub_ResponseResult and get_sub_departResult 's decorator below //[System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] //[System.Xml.Serialization.XmlArrayItemAttribute(Form=System.Xml.Schema.XmlSchemaForm..Unqualified, IsNullable=false,Namespace="")]