0
votes

I need to create a Delphi Unit file to process a XML file, normally I use the "XML DATA Binding wizard on Delphi" with the XSD file but in this case I only have the soap request message, like this:

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ar="http://ar.gov.afip.dif.FEV1/">
 <soapenv:Header/>
 <soapenv:Body>
 <ar:FECAESolicitar>
 <ar:Auth>
 <ar:Token>string</ar:Token>
 <ar:Sign>string</ar:Sign>
 <ar:Cuit>long</ar:Cuit>
 </ar:Auth>........

Are there any way to convert this into a xsd file?

1
Even tools do not know if there are 'optional' elements, allowed data/attribute values / data types etc.mjn

1 Answers

1
votes

A very old question with limited information, but anyway...

It is not really feasible to generate an xsd from the provided xml. However, a quick google search tells me that the service with the xmlns:ar="http://ar.gov.afip.dif.FEV1/"> has a wsdl reachable at https://servicios1.afip.gov.ar/wsfev1/service.asmx?WSDL.

The WSDL-file can be imported with Delphi's WSDL Importer directly from the IDE. The communication with the webservice can be handled in full by the RIO implementation.

If for some reason you don't want the SOAP-stuff you can run the WSDL Importer from the command line with the (undocumented/unsupported?) option "-schema".

C:\home>wsdlimp -schema service.wsdl Embarcadero WSDLIMP Version 2.41 - $Rev: 90173 $ Copyright (c) 2010 Embarcadero Technologies, Inc.

Reading: service.wsdl
Import : service.wsdl>0
Done   : service.wsdl>0
Writing: C:\home\service.pas

This works for plain xsd-files as well. This way only the types are processed. It looks quite different from the code generated by the XML Data Binding Wizard, but I like this format more. Force of habit, I guess.

Third, if you really want to use the XML Data Binding Wizard, you can copy the things between the tags in the wsdl into a new xsd (since the types are provided inside the schema in this case, aside from importing them from an xsd). You might have to fix some namespace mappings, but after that you can import it as usual.