NeTEx-CEN / NeTEx

NeTEx is a CEN Technical Standard for exchanging Public Transport schedules and related data.
http://netex-cen.eu
GNU General Public License v3.0
78 stars 40 forks source link

Import NeTEx_wsProducer-Document.wsdl #72

Open fxgenstudio opened 4 years ago

fxgenstudio commented 4 years ago

Hi, I try to import "NeTEx_wsProducer-Document.wsdl" from VS2017 in order to generate C# Classes.

I have some errors while importing service:

Severity Code Description Project File Line Suppression State Warning Custom tool warning: Cannot import wsdl:binding Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on. XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://www.siri.org.uk/siriWS']/wsdl:portType[@name='NetexProducerDocPort']

XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.siri.org.uk/siriWS']/wsdl:binding[@name='NetexProducerDocBinding'] ExportNetex C:\aaa\projects\SAEIV_sol\NETEX\ExportNetex\ExportNetex\Connected Services\ServiceReference1\Reference.svcmap 1

Thanks.

skinkie commented 4 years ago

In the last have year I have been working with some partners that were trying the same. I have received word that generating the classes from the Microsoft tools does not result in much success. There are some other paid products that seem to work for C#. It is still in our best interest to have our XSD / WSDL compatible with other products than xjb (java).

nick-knowles commented 4 years ago

Agreed - the question is how to arrive at a list of revisions needed to fix?

skinkie commented 4 years ago

Agreed - the question is how to arrive at a list of revisions needed to fix?

Some changes here resulted in XSD.exe to actually do something. But within DATA4PT we might get Microsoft on board for some actual development.

https://github.com/FlippieTrippie/NeTEx/commits/XSD.exe

acranton commented 3 years ago

Hi,

I'm trying to create C# classes using xsd.exe and even after adding in the comments suggested in https://github.com/FlippieTrippie/NeTEx/commits/XSD.exe I still get a circular reference error:

'SiteComponentGroup' from targetNamespace='http://www.netex.org.uk/netex' has invalid definition: Circular group reference.

Do you know how to get around this or if there is anywhere I can get a copy of the C# classes for this?

Thanks, Alex

skinkie commented 3 years ago

@acranton sadly we still don't have a magic bullet for C#.

acranton commented 3 years ago

Thanks for letting me know. I support and develop a large PT database for a couple of local authorities which currently exports to TransXChange and just starting to plan how best to incorporate a NetEx export. Guess I will need to try and manually create the class definitions based on the schema if there is no easy alternative.

skinkie commented 3 years ago

Thanks for letting me know. I support and develop a large PT database for a couple of local authorities which currently exports to TransXChange and just starting to plan how best to incorporate a NetEx export. Guess I will need to try and manually create the class definitions based on the schema if there is no easy alternative.

There are some appoaches. It seems that some commercial XML packages are able to generate classes that do work in C# but it might be that you would need them at runtime, which is bad in my perspective. The alternative is to use an existing NeTEx file, and generate classes from that. And you could switch to a language that would support this better...

acranton commented 3 years ago

Yeah I had a quick look at some of those but definitely don't want to be shipping an extra third party .dll file, I don't like that idea either. I think ill try using an XML file as a starting point, I just find the arrays/special types tend to require quite a bit of manual attention. If you could point me in the direction of a fairly comprehensive example NetEx xml file I could use for the import that would be really helpful.

Its tricky to introduce another language at this stage as the core application is bespoke, 20+ years old and written in Delphi (which has terrible serialization support) but is millions of lines of code so cant easily be migrated, but we have quite a few C# based modules/services/APIs which plug into it that I was planning to expand for this. I also haven't done any Java for a very long time so would be an added learning curve..

skinkie commented 3 years ago

Don't blame Delphi it works fine ;) I have been looking for projects that do XSD to 'other languages', I didn't find any of them out of the box supporting our NeTEx XSD. So we could do some work ourselves, but I have also been reaching out to many parties (including Microsoft) to solve the XSD to code issues.

acranton commented 3 years ago

Haha, I have been working in Delphi alongside C# since forever, it definitely still gets the job done but the syntactic sugar in C# does speed things up quite a lot! Plus hard to get support on Delphi online these days for those less standard type issues...

Thats good to hear, please do let me know if you manage to find a way to convert or hear of anyone who is happy to share the classes. Im probably not going to be taking this forwards immediately but its definitely on the todo list - if I end up creating the classes in C# ill probably make them available publicly (although haven't completely ruled out using Delphi just yet as the TXC code is all in there at the moment and can potentially re-use some of the data objects, although was going to move these to C# if the serialization was straightforward...)

skinkie commented 3 years ago

@acranton Ulf shared a possible solution. I have asked to post it here.

acranton commented 3 years ago

Thanks - any help gratefully received!

skinkie commented 3 years ago

@acranton (and others in this issue) would any of you be available to test classes? I currently have only one person in my "favor" list that is actually willing to test the results for C#, I would hope I could speed up the process if some other persons would be able to test what we currently have, to establish a baseline.

acranton commented 3 years ago

@skinkie yes, no problem, happy to help in any way to have class support for C#

budul100 commented 2 years ago

Hi,

I'm trying to create C# classes using xsd.exe and even after adding in the comments suggested in https://github.com/FlippieTrippie/NeTEx/commits/XSD.exe I still get a circular reference error:

'SiteComponentGroup' from targetNamespace='http://www.netex.org.uk/netex' has invalid definition: Circular group reference.

Do you know how to get around this or if there is anywhere I can get a copy of the C# classes for this?

Thanks, Alex

Hi Alex,

It is an old issue but at least I have found a "kind of" workaround. I have commented out the following parts to get around this exception (actually it would be better to determine the circle reference but I haven't found the root cause yet):

In _netex_ifopt_siteversion.xsd:

<!-- <xsd:element name="checkConstraints" type="checkConstraints_RelStructure" minOccurs="0">
    <xsd:annotation>
        <xsd:documentation>Impediments to navigation from processes or barriers. For example security, check in etc.</xsd:documentation>
    </xsd:annotation>
</xsd:element> -->
<!-- <xsd:group ref="AllEquipmentGroup"/> -->

In _netex_organisationversion.xsd:

<!-- <xsd:element name="alternativeNames" type="alternativeNames_RelStructure" minOccurs="0">
    <xsd:annotation>
        <xsd:documentation>Alternativie names for ORGANISATION.</xsd:documentation>
    </xsd:annotation>
</xsd:element>-->

And eventually in _netex_journeyPatternversion.xsd:

<!--    <xsd:element name="noticeAssignments" type="noticeAssignments_RelStructure" minOccurs="0">
    <xsd:annotation>
        <xsd:documentation>Notices for JOURNEY PATTERN Points may be </xsd:documentation>
    </xsd:annotation>
</xsd:element>-->

Then at least, I was able to create a C# model of NetEx part 1.

Regards, budul

skinkie commented 2 years ago

I would say, take the https://github.com/NeTEx-CEN/NeTEx-light from here, that creates the most common classes.

budul100 commented 2 years ago

Hi, I'm trying to create C# classes using xsd.exe and even after adding in the comments suggested in https://github.com/FlippieTrippie/NeTEx/commits/XSD.exe I still get a circular reference error: 'SiteComponentGroup' from targetNamespace='http://www.netex.org.uk/netex' has invalid definition: Circular group reference. Do you know how to get around this or if there is anywhere I can get a copy of the C# classes for this? Thanks, Alex

Hi Alex,

It is an old issue but at least I have found a "kind of" workaround. I have commented out the following parts to get around this exception (actually it would be better to determine the circle reference but I haven't found the root cause yet):

In _netex_ifopt_siteversion.xsd:

<!-- <xsd:element name="checkConstraints" type="checkConstraints_RelStructure" minOccurs="0">
  <xsd:annotation>
      <xsd:documentation>Impediments to navigation from processes or barriers. For example security, check in etc.</xsd:documentation>
  </xsd:annotation>
</xsd:element> -->
<!-- <xsd:group ref="AllEquipmentGroup"/> -->

In _netex_organisationversion.xsd:

<!-- <xsd:element name="alternativeNames" type="alternativeNames_RelStructure" minOccurs="0">
  <xsd:annotation>
      <xsd:documentation>Alternativie names for ORGANISATION.</xsd:documentation>
  </xsd:annotation>
</xsd:element>-->

And eventually in _netex_journeyPatternversion.xsd:

<!--  <xsd:element name="noticeAssignments" type="noticeAssignments_RelStructure" minOccurs="0">
  <xsd:annotation>
      <xsd:documentation>Notices for JOURNEY PATTERN Points may be </xsd:documentation>
  </xsd:annotation>
</xsd:element>-->

Then at least, I was able to create a C# model of NetEx part 1.

Regards, budul

Actually, I have found a solution now which solves the problems above completely. Instead of using xsd.exe, I have created the classes by using the XmlSchemaClassGenerator. By using this tool I was able to avoid any circular reference issues and it can furthermore create separate files for each class.

Together with the recommendation from @skinkie you should have a very fast and reliable solution.

skinkie commented 2 years ago

@budul100 indead, that tool is a life saver if you compare it to the standard C# stuff (and even the proprietary ones).

fxgenstudio commented 2 years ago

With XMLSpy you can create C# classes.

skinkie commented 2 years ago

With XMLSpy you can create C# classes.

I have heard that the quality is not what you are looking for :-)

ue71603 commented 2 years ago

@skinkie what do we do with this issue? Create a FAQ on github and refer to this one, but closed? Or do we have work here to do?

skinkie commented 2 years ago

Documentation, FAQ etc.