Reputation: 63
I would like to a) generate XML Requests b) and Parse Responses
based on a schema(.xsd) i have from one of the OEM.
I researched on net and generateDS seemed to be the one i was looking for however i am struggling to make it work.
I was able to generate Python Classes however I am not sure if this is the right approach.
I am trying to generate xml requests in runtime using python modules created from XSD, is this approach correct for production applications. OR should i be generating xml requests through xml.etree.ElementTree (I do understand that in the background generateDS is also using that).
When i am instantiating a class it doesn't generate the complete xml output.
end result should be something like this:
<BroadsoftDocument protocol = "OCI" xmlns="C" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sessionId xmlns="">123123</sessionId>
<command xsi:type="AuthenticationRequest" xmlns="">
<userId>12431232131</userId>
</command>
</BroadsoftDocument>```
Help on class AuthenticationRequest in module OCISchemaLogin_gds:
class AuthenticationRequest(OCIRequest)
| AuthenticationRequest(echo=None, userId=None, **kwargs_)
|
| AuthenticationRequest is 1st stage of the 2 stage OCI login process.
|
| Method resolution order:
| AuthenticationRequest
| OCIRequest
| OCICommand
| GeneratedsSuper
| builtins.object
|
| Methods defined here:
|
| __init__(self, echo=None, userId=None, **kwargs_)
| Initialize self. See help(type(self)) for accurate signature.
|
CODE:
auth_req = OCISchemaLogin_gds.AuthenticationRequest(userId = self.userId,)
command =[OCISchemaLogin_gds.OCICommand(extensiontype_='AuthenticationRequest') ]
message = OCISchemaLogin_gds.OCIMessage(protocol='OCI',sessionId=session, userId=self.userId, command= command)
message.export(sys.stdout,1)
OUTPUT:
<OCIMessage xmlns:None="C" protocol="OCI"> <sessionId>12421321</sessionId>
<userId>12321321</userId>
<OCICommand xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AuthenticationRequest"/>
</OCIMessage>
SUCCESSFUL
am I even using it correctly?
Upvotes: 1
Views: 2169
Reputation: 805
when you download genertaDS to your computer open tutorial/code/my_test.py get an example will build people.xml from people.xsd (xml schema). by the way it also create people_api.py based on the schema with all the classes.
stages: 1. running from cmd:
python generateDS.py -o people.py people.xsd
this will creating people_api.py based on the schema with all the classes. 2. running from cmd:
python my_test.py
this will getting a xml output to stdout.
Upvotes: 0