Come determinare quali file di schema (XSD) includere nella mia riga di comando Svcutil?
-
12-11-2019 - |
Domanda
Usando svcutil, sto cercando di generare una classe proxy per un Endpoint del servizio Web che segue il OGC CSW 2.0.2 (07-006R1) Standard per i servizi di catalogo.
Ho scaricato il interi file di schema OGC e li ha messi nella mia directory "D:/Temp/Ogcschemas/".
Lo schema che mi interessa è CSW, tuttavia lo schema CSW include e importa altri schemi ed è per questo che ho scaricato l'intero set.
Ad esempio, vedrai qualcosa di simile:
<wsdl:import namespace="http://www.opengis.net/cat/csw/2.0.2/requests" location="./xml-interfaces.wsdl"/>
<xsd:schema targetNamespace="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="2.0.2">
<xsd:include schemaLocation="../../csw/2.0.2/CSW-discovery.xsd"/>
<xsd:include schemaLocation="../../csw/2.0.2/CSW-publication.xsd"/>
</xsd:schema>
La mia riga di comando finora sembra:
svcutil D:\temp\OGCSchemas\csw\2.0.2\examples\wsdl\2.0.2\*.wsdl D:\temp\OGCSchemas\csw\2.0.2\*.xsd D:\temp\OGCSchemas\filter\1.1.0\*.xsd D:\temp\OGCSchemas\ows\1.0.0\*.xsd /out:D:\temp\ogc.csw.proxy.cs
Ma sto ricevendo molti errori che sembrano questo:
Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://www.opengis.net/cat/csw/2.0.2/soap']/wsdl:binding[@name='csw-SO
AP']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.opengis.net/cat/csw/2.0.2/wsdl']/wsdl:service[@name='CSW']/
wsdl:port[@name='csw-SOAP-Port']
Credo che questo errore mi stia dicendo di includere più XSD nella mia riga di comando.
Quindi la mia domanda è: Come posso determinare quali XSD includere nella mia riga di comando?
Pensavo di aver incluso un *.xsd per ogni directory da cui includeva, ma ovviamente no.
EDIT #1Quali sono le regole quando includono i file XSD? Tutti i file che vengono importati o inclusi devono essere aggiunti? Con uno schema così grande, penso che dovrò costruire uno strumento per trovarli tutti.
Soluzione
Non sono sicuro se questo fosse il modo giusto per farlo, ma ho creato un programma che passerebbe attraverso lo schema e creerebbe la mia riga di comando per me seguendo tutti i "XS: import", "wsdl: import", "xsd: include "," XSD: importazione "e" includono "gli elementi XML in modo ricorsivo.
Ho finito con la seguente riga di comando che ha finalmente ottenuto il codice generato. Ma il codice è molto piccolo. Qualcosa non va ancora. Ma almeno sono stato in grado di determinare quali file includere nella riga di comando.
riga di comando:
svcutil D:\temp\OGCSchemas\csw\2.0.2\http-binding.wsdl D:\temp\OGCSchemas\csw\2.0.2\xml-interfaces.wsdl D:\temp\OGCSchemas\csw\2.0.2\responses.wsdl D:\temp\OGCSchemas\csw\2.0.2\CSW-discovery.xsd D:\temp\OGCSchemas\csw\2.0.2\CSW-publication.xsd D:\temp\OGCSchemas\ows\1.0.0\owsExceptionReport.xsd D:\temp\OGCSchemas\csw\2.0.2\record.xsd D:\temp\OGCSchemas\ows\1.0.0\owsAll.xsd D:\temp\OGCSchemas\filter\1.1.0\filter.xsd D:\temp\OGCSchemas\csw\2.0.2\rec-dcterms.xsd D:\temp\OGCSchemas\csw\2.0.2\rec-dcmes.xsd D:\temp\OGCSchemas\ows\1.0.0\owsGetCapabilities.xsd D:\temp\OGCSchemas\filter\1.1.0\expr.xsd D:\temp\OGCSchemas\filter\1.1.0\sort.xsd D:\temp\OGCSchemas\filter\1.1.0\filterCapabilities.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryAggregates.xsd D:\temp\OGCSchemas\ows\1.0.0\owsServiceIdentification.xsd D:\temp\OGCSchemas\ows\1.0.0\owsServiceProvider.xsd D:\temp\OGCSchemas\ows\1.0.0\owsOperationsMetadata.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryPrimitives.xsd D:\temp\OGCSchemas\ows\1.0.0\owsDataIdentification.xsd D:\temp\OGCSchemas\ows\1.0.0\ows19115subset.xsd D:\temp\OGCSchemas\ows\1.0.0\owsCommon.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryBasic2d.xsd D:\temp\OGCSchemas\gml\3.1.1\base\geometryBasic0d1d.xsd D:\temp\OGCSchemas\gml\3.1.1\base\measures.xsd D:\temp\OGCSchemas\gml\3.1.1\base\units.xsd D:\temp\OGCSchemas\gml\3.1.1\base\dictionary.xsd D:\temp\OGCSchemas\gml\3.1.1\base\gmlBase.xsd D:\temp\OGCSchemas\gml\3.1.1\base\basicTypes.xsd D:\temp\OGCSchemas\xlink\1.0.0\xlinks.xsd /out:D:\temp\ogc.csw.proxy.cs
Ma il codice che genera è molto piccolo:
[assembly: System.Runtime.Serialization.ContractNamespaceAttribute("http://www.opengis.net/ows", ClrNamespace="www.opengis.net.ows")]
namespace www.opengis.net.ows
{
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
[System.Xml.Serialization.XmlRootAttribute(IsNullable=false)]
public partial class ExceptionReport : object, System.Xml.Serialization.IXmlSerializable
{
private System.Xml.XmlNode[] nodesField;
private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("ExceptionReport", "http://www.opengis.net/ows");
public System.Xml.XmlNode[] Nodes
{
get
{
return this.nodesField;
}
set
{
this.nodesField = value;
}
}
public void ReadXml(System.Xml.XmlReader reader)
{
this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader);
}
public void WriteXml(System.Xml.XmlWriter writer)
{
System.Runtime.Serialization.XmlSerializableServices.WriteNodes(writer, this.Nodes);
}
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
public static System.Xml.XmlQualifiedName ExportSchema(System.Xml.Schema.XmlSchemaSet schemas)
{
System.Runtime.Serialization.XmlSerializableServices.AddDefaultSchema(schemas, typeName);
return typeName;
}
}
}
Altri suggerimenti
L'ho affrontato l'altro giorno. Il modo più semplice è configurarli in IIS e modificare il file host per puntare quegli indirizzi sul tuo host locale. Quindi utilizzare XSD sul file WSDL principale e tutto andrà bene.
Sono sicuro che c'è un modo migliore, ma dopo alcune ore è quello che ho finito per fare.
Puoi provare a modificare gli spazi dei nomi, ma questo non ha funzionato per me più te 'DEVI modificarli per tutti i file e questo è un tale dolore.