python xsd within soap response -


i'm using spyne generating web services in server side python communicate excel client (xmla plugin), , have difficulties generate soap response match client request, want soap response ( under root tag schema "xsd:" refer xmlns:xsd="http://www.w3.org/2001/xmlschema in root :

<soap:envelope xmlns="urn:schemas-microsoft-com:xml-analysis">     <soap:body>        <discoverresponse xmlns="urn:...">           <return>                <root xmlns:xsd="http://www.w3.org/2001/xmlschema"                     xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"                     ....>                    < xsd:schema targetnamespace="urn:schemas-microsoft-com:xml-analysis:rowset"                    xmlns:sql="urn:schemas-microsoft-com:xml-sql">                 <xsd:element name="root">                 <xsd:complextype>                 <xsd:sequence minoccurs="0" maxoccurs="unbounded">                 <xsd:element name="row" type="row"/>                 </xsd:sequence>                 </xsd:complextype>                 </xsd:element>                 <xsd:simpletype name="uuid">                 <xsd:restriction base="xsd:string">                 <xsd:pattern value="[0-9a-za-z]{8}-[0-9a-za-z]{4}-[0-9a-za-z]{4}-[0-9a-za-z]{4}-[0-9a-za-z]{12}"/>                 </xsd:restriction>                 </xsd:simpletype>                 <xsd:complextype name="xmldocument">                 <xsd:sequence>                 <xsd:any/>                 </xsd:sequence>                 </xsd:complextype>                 <xsd:complextype name="row">                 <xsd:sequence>                 <xsd:element sql:field="propertyname" name="propertyname" type="xsd:string"/>                 <xsd:element sql:field="propertydescription" name="propertydescription" type="xsd:string" minoccurs="0"/>                 <xsd:element sql:field="propertytype" name="propertytype" type="xsd:string" minoccurs="0"/>                 <xsd:element sql:field="propertyaccesstype" name="propertyaccesstype" type="xsd:string"/>                 <xsd:element sql:field="isrequired" name="isrequired" type="xsd:boolean" minoccurs="0"/>                 <xsd:element sql:field="value" name="value" type="xsd:string" minoccurs="0"/>                 </xsd:sequence>                 </xsd:complextype>                 </xsd:schema>              </root>         </return>     </discoverresponse> </soap:body> 

the result got spyne every time doesn't contains xsd: :

  <soap11env:body> <tns:discoverresponse>   <tns:return>     <ns2:root xmlns:ns2="urn:schemas-microsoft-com:xml-analysis:rowset">       <ns3:schema xmlns:ns3="services.models" targetnamespace="urn:schemas-microsoft-com:xml-analysis:rowset"/>     </ns2:root>   </tns:return> </tns:discoverresponse> 

here python code :
in models.py file:

class schema(complexmodel): targetnamespace = xmlattribute(unicode) __type_name__ = "schema"  class discoverresponse(complexmodel): __namespace__ = "urn:schemas-microsoft-com:xml-analysis:rowset" root = array(schema.customize(max_occurs='unbounded')) 

in xmla.py file :

class xmla_provider(servicebase):      @rpc(unicode,      restrictionlist,      propertielist,      _returns=[discoverresponse],      _out_variable_names=["return"])          def discover(ctx, requesttype, restrictions, properties):             response = discoverresponse()             response.root = schema(targetnamespace="urn:schemas-microsoft-com:xml-analysis:rowset"),             return response 

to resolve problem tried add __ namespace __ = "http://www.w3.org/2001/xmlschema" in class schema , got problem
if child_ns != ns , not child_ns in self.imports[ns] , \ keyerror: 'http://www.w3.org/2001/xmlschema'

another solution comes mind , not solution, force soap response returning

<xsd:schema targetnamespace="urn:schemas-microsoft-com:xml-analysis:rowset"              xmlns:sql="urn:schemas-microsoft-com:xml-sql">....   

to root attribut unicode
here code: in xmla.py

  response.root = "\n  < xsd:schema xmlns:xsd='http://www.w3.org/2001/xmlschema' xmlns='urn:schemas-microsoft-com:xml-analysis:rowset' .... 

in model.py

class discoverresponse(complexmodel): __namespace__ = "urn:schemas-microsoft-com:xml-analysis:rowset" root = unicode 

and got output

debug:spyne.protocol.xml:response <soap11env:envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="urn:schemas-microsoft-com:xml-analysis">  <soap11env:body> <tns:discoverresponse>   <tns:return>     <ns0:root xmlns:ns0="urn:schemas-microsoft-com:xml-analysis:rowset">        &lt; xsd:schema xmlns:xsd='http://www.w3.org/2001/xmlschema'       xmlns='urn:schemas-microsoft-com:xml-analysis:rowset'       xmlns:xsi='http://www.w3.org/2001/xmlschema-instance'       xmlns:sql='urn:schemas-microsoft-com:xml-sql'         ....        /xsd:schema    </ns0:root>   </tns:return> </tns:discoverresponse> 

all < > characters replaced "& lt;" , "& gt;" (as said not solution, have solve problem name spaces )

please suggestion solve problem or in worst case, suggestion of soap library in python allow kind of response

you need switch bare mode , return anyxml this:

class discoverrequest(complexmodel):     requesttype = unicode     restrictions = restrictionlist     properties = propertielist   class helloworldservice(servicebase):     @rpc(discoverrequest, _returns=anyxml, _body_style="bare")     def discover(ctx, request):         return etree.fromstring("""<root>whatever</root>""") 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -