Menu

PyxbGen problems against a .Net wsdl

Help
wilson wu
2016-02-23
2016-02-23
  • wilson wu

    wilson wu - 2016-02-23

    Hi Peter,
    I have just recieved a .Net web services wsdl file. But I have couple of problems in using pyxbgen against it. First problem is there are multiple xsd:schema sections defined in the wsdl with different target namespace, which caused wsdl11.tDefintion class's buildMaps method to pick the wrong targetNamespace. I've tweaked the code to find the correct targetNamespace.

    But second issue is happenning now that some schema seem to be missed from the processing, which failed the resolveDefinition step in the final stage of creating the python files. I think it may be caused by the same issue: multiple xsd:schema sections defined.

    Can I send the wsdl file to you to have a look and see whether it can be supported by Pyxb?

    Much appreciated!

    Wilson

     
  • wilson wu

    wilson wu - 2016-02-23

    Here's wsdl file

     
  • Peter A. Bigot

    Peter A. Bigot - 2016-02-23

    This can be done, but it's not easy.

    The PyXB WSDL API assumes a WSDL file contains only a single schema. This could be fixed, but probably won't be because I'm only doing core maintenance on PyXB these days. If you want it fixed please file an issue on github and I may get to it some day.

    What you can do is extract each of the nine distinct schemas from the WSDL into their own schema files, then run PyXB on them as a group, saving the binding data in an archive file:

    pyxbgen \
      -u x1.xsd -m x1 \
      -u x2.xsd -m x2 \
      -u x3.xsd -m x3 \
      -u x4.xsd -m x4 \
      -u x5.xsd -m x5 \
      -u x6.xsd -m x6 \
      -u x7.xsd -m x7 \
      -u x8.xsd -m x8 \
      -u x9.xsd -m x9 \
      --archive-to-file epcba.wxs
    

    x1.xsd contains the schema for the http://ep.cba/core/services/communicationdispatch/v4 namespace. In that file you'll need to add xmlns:tns="http://ep.cba/core/services/communicationdispatch/v4"
    to the schema tag (in the WSDL file this was inherited from the container wsdl:definitions tag). The rest of the schemas don't need modification.

    At that point you have binding modules for all the schemas in the wsdl. You'll have to name them something that makes more sense than "x#".

    If you want to do something with the wsdl itself, you need to tell the wsdl processing about those namespaces. There's an old utility pyxbwsdl that parses wsdl files if the schemas are available; it works for a single inline schema, but won't work once the schemas have been removed.

    You can make it work by modifying it to add these two imports after the import of pyxb.bundles.wssplat.wsdl11:

    import pyxb.namespace
    pyxb.namespace.archive.NamespaceArchive.PreLoadArchives()
    

    Then you can do:

    PYXB_ARCHIVE_PATH=.:+ pyxbwsdl file:cbacba.wsdl
    

    which should produce:

    PS None
    Service: CommunicationDispatch
      Port CommunicationDispatch at http://localhost:0000/_CommunicationDispatchExport
        sendEmail (at action=http://ep.cba/core/services/communicationdispatch/v4/sendEmail)
          <pyxb.bundles.wssplat.raw.wsdl11.tDocumentation object at 0x7efff9725610>
          Input: {http://ep.cba/core/services/communicationdispatch/v4}sendEmailRequest
          Output: {http://ep.cba/core/services/communicationdispatch/v4}sendEmailResponse
        sendPushNotification (at action=http://ep.cba/core/services/communicationdispatch/v4/sendPushNotification)
          <pyxb.bundles.wssplat.raw.wsdl11.tDocumentation object at 0x7efff9725c10>
          Input: {http://ep.cba/core/services/communicationdispatch/v4}sendPushNotificationRequest
          Output: {http://ep.cba/core/services/communicationdispatch/v4}sendPushNotificationResponse
        sendUIBMessage (at action=http://ep.cba/core/services/communicationdispatch/v4/sendUIBMessage)
          <pyxb.bundles.wssplat.raw.wsdl11.tDocumentation object at 0x7efff972d590>
          Input: {http://ep.cba/core/services/communicationdispatch/v4}sendUIBMessageRequest
          Output: {http://ep.cba/core/services/communicationdispatch/v4}sendUIBMessageResponse
    

    Hope this is enough to get you going. There's some additional information on the techniques I've referenced in the PyXB documentation. Good luck.

     
  • Peter A. Bigot

    Peter A. Bigot - 2016-02-23

    Note: In the previous response, the cbacba.wsdl file processed by the modified pyxbdump has the wsdl:types element removed as the schemas are now external to the file. If you leave them in it probably won't work.

    Also if you just want to generate messages that conform to the wsdl, and aren't trying to process the service definitions themselves, you don't need the --archive-to-file directive when generating the bindings.

     
  • wilson wu

    wilson wu - 2016-02-23

    Thank you Peter, always so helpful. I'll try extracting the schemas into seperate xsd files.

     

Log in to post a comment.