Is it possible to define a complex type sequence with optional elements followed by n optional any elements?
Currently I have this XSD which violaets UPA:
<xs:complexType name="itemtype">
<xs:sequence>
<xs:element name="uuid" type="uuidtype"/>
<xs:element name="lastname" type="nametype"/>
<xs:element name="isActive" minOccurs="0" type="isactivetype"/>
<xs:element name="countries_scope" type="countryscopetype"/>
<xs:element name="origin" minOccurs="0" type="nametype"/>
<xs:element name="url" minOccurs="0" type="nametype"/>
<xs:element name="email" minOccurs="0" type="emailtype"/>
<xs:element name="description" minOccurs="0" type="nametype"/>
<xs:element name="town" minOccurs="0" type="nametype"/>
<xs:element name="role" minOccurs="0" type="nametype"/>
<xs:element name="source" minOccurs="0" type="nametype"/>
<xs:element name="origin_zip" minOccurs="0" type="nametype"/>
<xs:element name="town_zip" minOccurs="0" type="nametype"/>
<xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
</xs:sequence>
</xs:complexType>
A possible XML could be:
<item>
<uuid>1</uuid>
<lastname>Yanick</lastname>
<country_scope>CHE</country_scope>
<role>Student</role>
<age>24</age>
</item>
Here only the optional role is used and age would be one any element.
The solution is simple. THe last element bevore the any can't be an optional.
This XSD would work:
<xs:complexType name="itemtype">
<xs:sequence>
<xs:element name="uuid" type="uuidtype"/>
<xs:element name="lastname" type="nametype"/>
<xs:element name="isActive" minOccurs="0" type="isactivetype"/>
<xs:element name="origin" minOccurs="0" type="nametype"/>
<xs:element name="url" minOccurs="0" type="nametype"/>
<xs:element name="email" minOccurs="0" type="emailtype"/>
<xs:element name="description" minOccurs="0" type="nametype"/>
<xs:element name="town" minOccurs="0" type="nametype"/>
<xs:element name="role" minOccurs="0" type="nametype"/>
<xs:element name="source" minOccurs="0" type="nametype"/>
<xs:element name="origin_zip" minOccurs="0" type="nametype"/>
<xs:element name="town_zip" minOccurs="0" type="nametype"/>
<xs:element name="countries_scope" type="countryscopetype"/>
<xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
</xs:sequence>
Related
I'm looking to add a thirdparty target type to NLog.xsd. You would normally create a nlog.config file like this:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
...>
...
<targets>
<target name="file" xsi:type="File" />
</targets>
...
</nlog>
Now I want to add a new target:
<targets>
<target name="file" xsi:type="File" />
<target name="file" xsi:type="MyTarget" />
</targets>
XSD validation warns inside Visual Studio, since MyTarget isn't defined anywhere. I have tried adding MyTarget to NLog.xsd and reference the updated NLog.xsd, but then I get no intellisense what so ever:
<nlog xmlns="http://my-project.com/NLog.xsd" ...>
Any ideas how to implement this?
The custom Syslog target (NLog.Targets.Syslog) has created a custom XSD that extends the XSD of NLog.
Content:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NLog.Targets.Syslog"
elementFormDefault="qualified"
targetNamespace="http://www.nlog-project.org/schemas/NLog.Targets.Syslog.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sl="http://www.nlog-project.org/schemas/NLog.Targets.Syslog.xsd"
xmlns:nlog="http://www.nlog-project.org/schemas/NLog.xsd">
<xs:import namespace="http://www.nlog-project.org/schemas/NLog.xsd" />
<xs:complexType name="Syslog">
<xs:complexContent>
<xs:extension base="nlog:Target">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="layout" type="nlog:Layout" minOccurs="0" maxOccurs="1" />
<xs:element name="enforcement" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="throttling" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="limit" type="xs:integer" minOccurs="0" maxOccurs="1" />
<xs:element name="strategy" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="delay" type="xs:decimal" minOccurs="0" maxOccurs="1" />
</xs:choice>
<xs:attribute name="limit" type="xs:integer" />
<xs:attribute name="strategy" type="xs:string" />
<xs:attribute name="delay" type="xs:decimal" />
</xs:complexType>
</xs:element>
<xs:element name="messageProcessors" type="xs:integer" minOccurs="0" maxOccurs="1" />
<xs:element name="splitOnNewLine" type="xs:boolean" minOccurs="0" maxOccurs="1" />
<xs:element name="transliterate" type="xs:boolean" minOccurs="0" maxOccurs="1" />
<xs:element name="replaceInvalidCharacters" type="xs:boolean" minOccurs="0" maxOccurs="1" />
<xs:element name="truncateFieldsToMaxLength" type="xs:boolean" minOccurs="0" maxOccurs="1" />
<xs:element name="truncateMessageTo" type="xs:integer" minOccurs="0" maxOccurs="1" />
</xs:choice>
<xs:attribute name="messageProcessors" type="xs:integer" />
<xs:attribute name="splitOnNewLine" type="xs:boolean" />
<xs:attribute name="transliterate" type="xs:boolean" />
<xs:attribute name="replaceInvalidCharacters" type="xs:boolean" />
<xs:attribute name="truncateFieldsToMaxLength" type="xs:boolean" />
<xs:attribute name="truncateMessageTo" type="xs:integer" />
</xs:complexType>
</xs:element>
<xs:element name="messageCreation" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="facility" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="rfc" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="rfc3164" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="hostname" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="tag" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:choice>
<xs:attribute name="hostname" type="xs:string" />
<xs:attribute name="tag" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="rfc5424" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="hostname" type="nlog:Layout" minOccurs="0" maxOccurs="1" />
<xs:element name="appName" type="nlog:Layout" minOccurs="0" maxOccurs="1" />
<xs:element name="procId" type="nlog:Layout" minOccurs="0" maxOccurs="1" />
<xs:element name="msgId" type="nlog:Layout" minOccurs="0" maxOccurs="1" />
<xs:element name="structuredData" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="fromEventProperties" type="nlog:Layout" minOccurs="0" maxOccurs="1" />
<xs:element name="sdElement" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="sdParam" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="value" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="sdId" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="disableBom" type="xs:boolean" minOccurs="0" maxOccurs="1" />
</xs:choice>
<xs:attribute name="hostname" type="nlog:SimpleLayoutAttribute" />
<xs:attribute name="appName" type="nlog:SimpleLayoutAttribute" />
<xs:attribute name="procId" type="nlog:SimpleLayoutAttribute" />
<xs:attribute name="msgId" type="nlog:SimpleLayoutAttribute" />
<xs:attribute name="disableBom" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="messageSend" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="protocol" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="udp" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="server" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="port" type="xs:integer" minOccurs="0" maxOccurs="1" />
</xs:choice>
<xs:attribute name="server" type="xs:string" />
<xs:attribute name="port" type="xs:integer" />
</xs:complexType>
</xs:element>
<xs:element name="tcp" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="server" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="port" type="xs:integer" minOccurs="0" maxOccurs="1" />
<xs:element name="keepAlive" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="enabled" type="xs:boolean" minOccurs="0" maxOccurs="1" />
<xs:element name="timeout" type="xs:integer" minOccurs="0" maxOccurs="1" />
<xs:element name="interval" type="xs:integer" minOccurs="0" maxOccurs="1" />
</xs:choice>
<xs:attribute name="enabled" type="xs:boolean" />
<xs:attribute name="timeout" type="xs:integer" />
<xs:attribute name="interval" type="xs:integer" />
</xs:complexType>
</xs:element>
<xs:element name="reconnectInterval" type="xs:integer" minOccurs="0" maxOccurs="1" />
<xs:element name="useTls" type="xs:boolean" minOccurs="0" maxOccurs="1" />
<xs:element name="framing" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="dataChunkSize" type="xs:integer" minOccurs="0" maxOccurs="1" />
</xs:choice>
<xs:attribute name="server" type="xs:string" />
<xs:attribute name="port" type="xs:integer" />
<xs:attribute name="reconnectInterval" type="xs:integer" />
<xs:attribute name="useTls" type="xs:boolean" />
<xs:attribute name="framing" type="xs:string" />
<xs:attribute name="dataChunkSize" type="xs:integer" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="layout" type="nlog:SimpleLayoutAttribute" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Usage: (this one is published on http://nlog-project.org/)
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sl="http://www.nlog-project.org/schemas/NLog.Targets.Syslog.xsd">
and
<target xsi:type="sl:Syslog" name="syslog3164-tgt">
instead of
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
See also https://github.com/NLog/NLog.github.io/pull/56
Update: Visual Studio also needed this:
<nlog xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.Targets.Syslog.xsd http://www.nlog-project.org/schemas/NLog.Targets.Syslog.xsd" .. >
In few words, there are around 100 soap web services and I need to expose them as rest via NodeJs. I mean, for each soap service there will a single rest service playing the role of a facade.
I install "npm install soap" as explained in https://github.com/vpulim/node-soap and https://github.com/23/node-soap. The example below is working properly so I understand the installation is fine.
So, my strach question is: how can I read the wsdl below? Kindly, see how I am trying by following the success example and I am getting certain error which seems I am missing some extra word in "client.CadastroService.CadastroServiceSoapBinding.consultarDados". Well, the wdls from such example has a small difference from my wsdl. The example relies on "wsdl:input wsaw:Action=..." and mine doesn't use wsaw:Action at all. I guess it doesn't change the way I have to call it. I am calling following this pattern: "wsdl:service name"."wsdl:binding name"."wsdl:message name"
Example working:
var soap = require('soap');
var url = "http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl";
var args = {"tns:request":"GOOG"};
soap.createClient(url, function(err, client){
client.CadastroService.BasicHttpBinding_IStockQuoteService.GetStockQuote(args, function(err, result){
if (err) throw err;
console.log(result);
});
});
My wsdl (obviously edited to make simpler):
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://service.ws.mycompany.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="CadastroService" targetNamespace="http://service.ws.mycompany.com/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://service.ws.mycompany.com/" elementFormDefault="unqualified" targetNamespace="http://service.ws.mycompany.com/" version="1.0">
<xs:element name="consultarDados" type="tns:consultarDados"/>
<xs:element name="root" nillable="true" type="xs:anyType"/>
<xs:complexType name="basicResponse">
<xs:sequence>
<xs:element minOccurs="0" name="codigoRetorno" type="xs:string"/>
<xs:element minOccurs="0" name="mensagemRetorno" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="consultarDados">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:ConsultarInput"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ConsultarInput">
<xs:sequence>
<xs:element minOccurs="0" name="numCartao" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="consultarDadosResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:ConsultarResponse"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ConsultarResponse">
<xs:complexContent>
<xs:extension base="tns:basicResponse">
<xs:sequence>
<xs:element minOccurs="0" name="blockCode" type="xs:string"/>
<xs:element minOccurs="0" name="blockCode2" type="xs:string"/>
<xs:element minOccurs="0" name="codBloqueioBoletimProtecao" type="xs:string"/>
<xs:element minOccurs="0" name="codLogo" type="xs:string"/>
<xs:element minOccurs="0" name="codMotivoEmissao2via" type="xs:string"/>
<xs:element minOccurs="0" name="codProdutoDN" type="xs:string"/>
<xs:element minOccurs="0" name="dataAberturaConta" type="xs:string"/>
<xs:element minOccurs="0" name="dataCancelamento" type="xs:string"/>
<xs:element minOccurs="0" name="dataEmissaoCartao" type="xs:string"/>
<xs:element minOccurs="0" name="dataExclusaoBoletimProtecao" type="xs:string"/>
<xs:element minOccurs="0" name="dataExpiracaoConta" type="xs:string"/>
<xs:element minOccurs="0" name="dataGeracaoPlastico" type="xs:string"/>
<xs:element minOccurs="0" name="dataInclusaoBoletimProtecao" type="xs:string"/>
<xs:element minOccurs="0" name="dataInicioAtraso" type="xs:string"/>
<xs:element minOccurs="0" name="dataNascimento" type="xs:string"/>
<xs:element minOccurs="0" name="dataProximoCorte" type="xs:string"/>
<xs:element minOccurs="0" name="dataProximoVencto" type="xs:string"/>
<xs:element minOccurs="0" name="dataUltimaAlteracaoLimite" type="xs:string"/>
<xs:element minOccurs="0" name="dataUltimaAlteracaoVencto" type="xs:string"/>
<xs:element minOccurs="0" name="dataUltimoPagamento" type="xs:string"/>
<xs:element minOccurs="0" name="dataValidadePlastico" type="xs:string"/>
<xs:element minOccurs="0" name="dataVenctoPenultimaFatura" type="xs:string"/>
<xs:element minOccurs="0" name="dataVenctoUltFatura" type="xs:string"/>
<xs:element minOccurs="0" name="dddCelular1" type="xs:string"/>
<xs:element minOccurs="0" name="dddCelular2" type="xs:string"/>
<xs:element minOccurs="0" name="dddComercial" type="xs:string"/>
<xs:element minOccurs="0" name="dddResidencial" type="xs:string"/>
<xs:element minOccurs="0" name="ddiCelular1" type="xs:string"/>
<xs:element minOccurs="0" name="ddiCelular2" type="xs:string"/>
<xs:element minOccurs="0" name="ddiComercial" type="xs:string"/>
<xs:element minOccurs="0" name="ddiResidencial" type="xs:string"/>
<xs:element minOccurs="0" name="descTipoPessoa" type="xs:string"/>
<xs:element minOccurs="0" name="diaCorteAtual" type="xs:string"/>
<xs:element minOccurs="0" name="diaVencimento" type="xs:string"/>
<xs:element minOccurs="0" name="endereco" type="xs:string"/>
<xs:element minOccurs="0" name="enderecoBairro" type="xs:string"/>
<xs:element minOccurs="0" name="enderecoCEP" type="xs:string"/>
<xs:element minOccurs="0" name="enderecoCidade" type="xs:string"/>
<xs:element minOccurs="0" name="enderecoComplemento" type="xs:string"/>
<xs:element minOccurs="0" name="enderecoNumero" type="xs:string"/>
<xs:element minOccurs="0" name="enderecoUF" type="xs:string"/>
<xs:element minOccurs="0" name="estadoCivilDesc" type="xs:string"/>
<xs:element minOccurs="0" name="flagTipoFaturamento" type="xs:string"/>
<xs:element minOccurs="0" name="indClienteVip" type="xs:string"/>
<xs:element minOccurs="0" name="indClienteVipDesc" type="xs:string"/>
<xs:element minOccurs="0" name="indDebitoAutomatico" type="xs:string"/>
<xs:element minOccurs="0" name="indEstadoCivil" type="xs:string"/>
<xs:element minOccurs="0" name="indLimiteSegregado" type="xs:string"/>
<xs:element minOccurs="0" name="indSexo" type="xs:string"/>
<xs:element minOccurs="0" name="indicadorCartaoBloqueado" type="xs:string"/>
<xs:element minOccurs="0" name="indicadorCartaoOuConta" type="xs:string"/>
<xs:element minOccurs="0" name="indicadorCompraParcelada" type="xs:string"/>
<xs:element minOccurs="0" name="indicadorContato" type="xs:string"/>
<xs:element minOccurs="0" name="indicadorTeleSaque" type="xs:string"/>
<xs:element minOccurs="0" name="nomeMae" type="xs:string"/>
<xs:element minOccurs="0" name="nomeOrg" type="xs:string"/>
<xs:element minOccurs="0" name="nomePai" type="xs:string"/>
<xs:element minOccurs="0" name="nomePortator" type="xs:string"/>
<xs:element minOccurs="0" name="numCartaoAnterior" type="xs:string"/>
<xs:element minOccurs="0" name="numCartaoTitular" type="xs:string"/>
<xs:element minOccurs="0" name="numCelular1" type="xs:string"/>
<xs:element minOccurs="0" name="numCelular2" type="xs:string"/>
<xs:element minOccurs="0" name="numChpras" type="xs:string"/>
<xs:element minOccurs="0" name="numComercial" type="xs:string"/>
<xs:element minOccurs="0" name="numConta" type="xs:string"/>
<xs:element minOccurs="0" name="numCpfCnpj" type="xs:string"/>
<xs:element minOccurs="0" name="numOrg" type="xs:string"/>
<xs:element minOccurs="0" name="numRG" type="xs:string"/>
<xs:element minOccurs="0" name="numResidencial" type="xs:string"/>
<xs:element name="qtdAdicionais" type="xs:int"/>
<xs:element name="qtdCompraParceladaAtual" type="xs:int"/>
<xs:element name="qtdDiasAtrasoUltimaFatura" type="xs:int"/>
<xs:element minOccurs="0" name="qtdVezesFaturamentoConta" type="xs:string"/>
<xs:element name="saldoAFaturar" type="xs:double"/>
<xs:element name="saldoAntepenultimaFatura" type="xs:double"/>
<xs:element name="saldoCompraInter" type="xs:double"/>
<xs:element name="saldoFaturaFechada" type="xs:double"/>
<xs:element name="saldoInterFatura" type="xs:double"/>
<xs:element name="saldoInterUltimaFaturaFechada" type="xs:double"/>
<xs:element minOccurs="0" name="sexoDesc" type="xs:string"/>
<xs:element minOccurs="0" name="situacaoConta" type="xs:string"/>
<xs:element minOccurs="0" name="situacaoContaDesc" type="xs:string"/>
<xs:element name="taxaCashProxPeriodo" type="xs:double"/>
<xs:element name="taxaJurosProxPeriodo" type="xs:double"/>
<xs:element minOccurs="0" name="tipoCartao" type="xs:string"/>
<xs:element minOccurs="0" name="tipoPessoa" type="xs:string"/>
<xs:element minOccurs="0" name="tipoPortador" type="xs:string"/>
<xs:element minOccurs="0" name="tipoPortadorDesc" type="xs:string"/>
<xs:element name="totalCashAFaturar" type="xs:double"/>
<xs:element name="valorAtraso" type="xs:double"/>
<xs:element name="valorLimiteCash" type="xs:double"/>
<xs:element name="valorLimiteCashInter" type="xs:double"/>
<xs:element name="valorLimiteCredito" type="xs:double"/>
<xs:element name="valorLimiteCreditoInter" type="xs:double"/>
<xs:element name="valorLimiteDispCash" type="xs:double"/>
<xs:element name="valorLimiteDispCashInter" type="xs:double"/>
<xs:element name="valorLimiteDispCredito" type="xs:double"/>
<xs:element name="valorLimiteDispCreditoInter" type="xs:double"/>
<xs:element name="valorLimiteParcDisponivelSegregado" type="xs:double"/>
<xs:element name="valorLimiteParcTotalSegregado" type="xs:double"/>
<xs:element name="valorPagtoMinimoUltFatura" type="xs:double"/>
<xs:element name="valorUltimoPagamento" type="xs:double"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="consultarDados">
<wsdl:part element="tns:consultarDados" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="Cadastro">
<wsdl:operation name="consultarDados">
<wsdl:input message="tns:consultarDados" name="consultarDados">
</wsdl:input>
<wsdl:output message="tns:consultarDadosResponse" name="consultarDadosResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CadastroServiceSoapBinding" type="tns:Cadastro">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="consultarDados">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="consultarDados">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="consultarDadosResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CadastroService">
<wsdl:port binding="tns:CadastroServiceSoapBinding" name="CadastroPort">
<soap:address location="http://myip...:myport/ws-myapp/cadastro"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Entire error:
demetrio#nodejs ~/dev/NodeJsSrc $ node consultaDados.js
/home/demetrio/dev/NodeJsSrc/consultaDados.js:9
client.CadastroService.CadastroServiceSoapBinding.consultarDados(args, function(err, result){
^
TypeError: Cannot read property 'consultarDados' of undefined
at /home/demetrio/dev/NodeJsSrc/consultaDados.js:9:54
at /home/demetrio/node_modules/soap/lib/soap.js:58:5
at null.callback (/home/demetrio/node_modules/soap/lib/soap.js:25:9)
at /home/demetrio/node_modules/soap/lib/wsdl.js:1073:12
at WSDL._processNextInclude (/home/demetrio/node_modules/soap/lib/wsdl.js:1148:12)
at WSDL.processIncludes (/home/demetrio/node_modules/soap/lib/wsdl.js:1191:8)
at /home/demetrio/node_modules/soap/lib/wsdl.js:1028:10
at nextTickCallbackWith0Args (node.js:419:9)
at process._tickCallback (node.js:348:13)
demetrio#nodejs ~/dev/NodeJsSrc $
How I am trying to read the soap web service (I basically followed the above example working)
var soap = require('soap');
var url = "http://myIp...:myPort/ws-myApp/cadastro?wsdl";
var args = {"tns:request":"GOOG"};
soap.createClient(url, function(err, client){
client.CadastroService.CadastroServiceSoapBinding.consultarDados(args, function(err, result){
if (err) throw err;
console.log(result);
});
});
I have a wsdl that includes a couple of import schema statements, as follows:
<types>
**<xsd:schema>
<xsd:import namespace="http://quickfeedback.ws.cdb.skoda.vwg"
schemaLocation="CDBQuickFeedbackService_schema1.xsd"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://common.ws.cdb.skoda.vwg"
schemaLocation="CDBQuickFeedbackService_schema2.xsd"/>
</xsd:schema>**
I am using a tool (wsdl2rpg) that will create interfaces into the wsdl, but unfortunately, it does not support/recognise imports. Therefore I need to copy the code from the .xsd into the wsdl.
As a complete newbie to this, I am not sure exactly what code I should copy. Below is schema1, can somebody please advise what I should copy and where to ? I have tried a couple of times, with what I think are logical blocks etc., but they do not seem to work (i.e. the tool still does not pick up the copied code).
<?xml version="1.0" encoding="UTF-8"?><!--Generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, (build IBM 2.2.3-11/25/2013 12:35 PM(foreman)-)
See http://java.sun.com/xml/jaxb --><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://quickfeedback.ws.cdb.skoda.vwg" xmlns:ns1="http://common.ws.cdb.skoda.vwg" version="1.0" targetNamespace="http://quickfeedback.ws.cdb.skoda.vwg">
<xs:import namespace="http://common.ws.cdb.skoda.vwg" schemaLocation="CDBQuickFeedbackService_schema2.xsd"></xs:import>
<xs:element name="GetQuickFeedbackEventsRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="BID" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Brand" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Type" type="xs:integer" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetQuickFeedbackEventsResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="ResultSet" type="ns1:ResultSetType" minOccurs="0"></xs:element>
<xs:element name="EventSet" type="tns:QuickFeedbackEventSetType" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetQuickFeedbackResultsRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="Date" type="xs:date" minOccurs="0"></xs:element>
<xs:element name="BID" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetQuickFeedbackResultsResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="QuickFeedbackResultSet" type="tns:QuickFeedbackResultSetType" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetRejectedAgreementCustomersCountRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="RejectionDate" type="xs:date" minOccurs="0"></xs:element>
<xs:element name="BID" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetRejectedAgreementCustomersCountResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="ResulSet" type="ns1:ResultSetType" minOccurs="0"></xs:element>
<xs:element name="Count" type="xs:int"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetRejectedAgreementCustomersRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="RejectionDate" type="xs:date" minOccurs="0"></xs:element>
<xs:element name="BID" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetRejectedAgreementCustomersResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="ResulSet" type="ns1:ResultSetType" minOccurs="0"></xs:element>
<xs:element name="DataSet" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Customer" type="tns:GetRejectedAgreementCustomerType" minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
<xs:attribute name="Count" type="xs:int" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="InsertQuickFeedbackEventsRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="EventSet" type="tns:QuickFeedbackEventSetType"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="InsertQuickFeedbackEventsResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="ResultSet" type="ns1:ResultSetType" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="InsertQuickFeedbackResultsRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="QuickFeedbackResultSet" type="tns:QuickFeedbackResultSetType" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="InsertQuickFeedbackResultsResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="ResultSet" type="ns1:ResultSetType" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="GetRejectedAgreementCustomerType">
<xs:sequence>
<xs:element name="ID" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Email" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Phone" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Details" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Detail" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:extension base="tns:QuickFeedbackCustomerType">
<xs:sequence>
<xs:element name="Date" type="xs:dateTime"></xs:element>
</xs:sequence>
<xs:attribute name="Number" type="xs:int"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Count" type="xs:int"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="Cars" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Car" type="tns:CarType" maxOccurs="unbounded"></xs:element>
</xs:sequence>
<xs:attribute name="Count" type="xs:int"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="StudyId" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="Period" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="SurveyNumber" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="DeliveryDate" type="xs:date" minOccurs="0"></xs:element>
<xs:element name="EventType" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="ReturnReason" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="QuestionnaireDate" type="xs:date" minOccurs="0"></xs:element>
</xs:sequence>
<xs:attribute name="Number" type="xs:int"></xs:attribute>
</xs:complexType>
<xs:complexType name="QuickFeedbackCustomerType">
<xs:sequence>
<xs:element name="Salutation" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Firstname" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Lastname" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Email" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Phone" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Street" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="City" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="PostalCode" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Country" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="CarType">
<xs:sequence>
<xs:element name="Brand" type="xs:string"></xs:element>
<xs:element name="VIN" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Model" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="QuickFeedbackEventType">
<xs:sequence>
<xs:element name="StudyId" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="Period" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="SurveyNumber" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="Date" type="xs:dateTime"></xs:element>
<xs:element name="Type" type="xs:integer"></xs:element>
<xs:element name="Customer">
<xs:complexType>
<xs:complexContent>
<xs:extension base="tns:QuickFeedbackCustomerType">
<xs:sequence>
<xs:element name="ID" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Car" type="tns:CarType"></xs:element>
<xs:element name="Organization" type="tns:OrganizationType" minOccurs="0"></xs:element>
<xs:element name="Importer" type="tns:ImporterType"></xs:element>
<xs:element name="ManualImport" type="xs:integer"></xs:element>
</xs:sequence>
<xs:attribute name="Number" type="xs:int" use="required"></xs:attribute>
</xs:complexType>
<xs:complexType name="OrganizationType">
<xs:sequence>
<xs:element name="Country" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Code" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="EngineerCode" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ImporterType">
<xs:sequence>
<xs:element name="BID" type="xs:string"></xs:element>
<xs:element name="Country" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="QuickFeedbackResultSetType">
<xs:sequence>
<xs:element name="QuickFeedbackResult" type="tns:QuickFeedbackResultType" maxOccurs="unbounded"></xs:element>
</xs:sequence>
<xs:attribute name="Count" type="xs:int" use="required"></xs:attribute>
</xs:complexType>
<xs:complexType name="QuickFeedbackResultType">
<xs:sequence>
<xs:element name="StudyId" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="Period" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="SurveyNumber" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="DeliveryDate" type="xs:date" minOccurs="0"></xs:element>
<xs:element name="EventType" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="ReturnReason" type="xs:integer" minOccurs="0"></xs:element>
<xs:element name="QuestionnaireDate" type="xs:date" minOccurs="0"></xs:element>
<xs:element name="Customer" type="tns:CustomerIdType"></xs:element>
<xs:element name="BID" type="xs:string"></xs:element>
</xs:sequence>
<xs:attribute name="Number" type="xs:int" use="required"></xs:attribute>
</xs:complexType>
<xs:complexType name="CustomerIdType">
<xs:sequence>
<xs:element name="ID" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Email" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Phone" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="QuickFeedbackEventSetType">
<xs:sequence>
<xs:element name="Event" type="tns:QuickFeedbackEventType" maxOccurs="unbounded"></xs:element>
</xs:sequence>
<xs:attribute name="Count" type="xs:int" use="required"></xs:attribute>
</xs:complexType>
</xs:schema>
The <types> element may contain zero or various <xsd:schema> elements, and the content of each of those can be either an import of an external xsd file (or more than one) or the schema itself.
Note that in your schema1 you are also importing schema2.xsd
<xs:import namespace="http://common.ws.cdb.skoda.vwg" schemaLocation="CDBQuickFeedbackService_schema2.xsd"></xs:import>
In your case you have two options:
Create two schema elements inside types element
<definitions>
<types>
<xsd:schema>
<!-- content of schema2.xsd -->
</xsd:schema>
<xsd:schema>
<!-- content of schema1.xsd -->
</xsd:schema>
</types>
</definitions>
Create one combined schema element inside types element
This is also a straight-forward solution since you only have to dump the content of both xsd files into an element but you have to pay attention to the namespaces declared.
In schema1 you have these namespaces:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://common.ws.cdb.skoda.vwg"
targetNamespace="http://quickfeedback.ws.cdb.skoda.vwg"
xmlns:tns="http://quickfeedback.ws.cdb.skoda.vwg" >
ns1 was declared so you could use the types from that namespace, which refers to the targetnamespace of schema2.xsd. So if you open schema2.xsd you should see something like this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://common.ws.cdb.skoda.vwg"
targetNamespace="http://common.ws.cdb.skoda.vwg"
xmlns:tns="http://common.ws.cdb.skoda.vwg" >
But now, since you are combining both schemas into one, you only need one targetnamespace and you already don't need ns1. So your wsdl should look like this:
<definitions>
<types>
<xs:schema targetNamespace="http://quickfeedback.ws.cdb.skoda.vwg" xmlns:tns="http://quickfeedback.ws.cdb.skoda.vwg" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Here copy the content of schema2.xsd without the <xs:schema>element -->
<xs:element name="GetQuickFeedbackEventsRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="BID" type="xs:string"/>
<xs:element minOccurs="0" name="Brand" type="xs:string"/>
<xs:element minOccurs="0" name="Type" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetQuickFeedbackEventsResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ResultSet" type="tns:ResultSetType"/>
<xs:element minOccurs="0" name="EventSet" type="tns:QuickFeedbackEventSetType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetQuickFeedbackResultsRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="Date" type="xs:date"/>
<xs:element minOccurs="0" name="BID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetQuickFeedbackResultsResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="QuickFeedbackResultSet" type="tns:QuickFeedbackResultSetType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetRejectedAgreementCustomersCountRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="RejectionDate" type="xs:date"/>
<xs:element minOccurs="0" name="BID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetRejectedAgreementCustomersCountResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ResulSet" type="tns:ResultSetType"/>
<xs:element name="Count" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetRejectedAgreementCustomersRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="RejectionDate" type="xs:date"/>
<xs:element minOccurs="0" name="BID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetRejectedAgreementCustomersResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ResulSet" type="tns:ResultSetType"/>
<xs:element minOccurs="0" name="DataSet">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="Customer" type="tns:GetRejectedAgreementCustomerType"/>
</xs:sequence>
<xs:attribute name="Count" type="xs:int" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="InsertQuickFeedbackEventsRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="EventSet" type="tns:QuickFeedbackEventSetType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="InsertQuickFeedbackEventsResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ResultSet" type="tns:ResultSetType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="InsertQuickFeedbackResultsRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="QuickFeedbackResultSet" type="tns:QuickFeedbackResultSetType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="InsertQuickFeedbackResultsResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ResultSet" type="tns:ResultSetType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="GetRejectedAgreementCustomerType">
<xs:sequence>
<xs:element minOccurs="0" name="ID" type="xs:string"/>
<xs:element minOccurs="0" name="Email" type="xs:string"/>
<xs:element minOccurs="0" name="Phone" type="xs:string"/>
<xs:element minOccurs="0" name="Details">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Detail">
<xs:complexType>
<xs:complexContent>
<xs:extension base="tns:QuickFeedbackCustomerType">
<xs:sequence>
<xs:element name="Date" type="xs:dateTime"/>
</xs:sequence>
<xs:attribute name="Number" type="xs:int"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Count" type="xs:int"/>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="Cars">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Car" type="tns:CarType"/>
</xs:sequence>
<xs:attribute name="Count" type="xs:int"/>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="StudyId" type="xs:integer"/>
<xs:element minOccurs="0" name="Period" type="xs:integer"/>
<xs:element minOccurs="0" name="SurveyNumber" type="xs:integer"/>
<xs:element minOccurs="0" name="DeliveryDate" type="xs:date"/>
<xs:element minOccurs="0" name="EventType" type="xs:integer"/>
<xs:element minOccurs="0" name="ReturnReason" type="xs:integer"/>
<xs:element minOccurs="0" name="QuestionnaireDate" type="xs:date"/>
</xs:sequence>
<xs:attribute name="Number" type="xs:int"/>
</xs:complexType>
<xs:complexType name="QuickFeedbackCustomerType">
<xs:sequence>
<xs:element minOccurs="0" name="Salutation" type="xs:string"/>
<xs:element minOccurs="0" name="Firstname" type="xs:string"/>
<xs:element minOccurs="0" name="Lastname" type="xs:string"/>
<xs:element minOccurs="0" name="Email" type="xs:string"/>
<xs:element minOccurs="0" name="Phone" type="xs:string"/>
<xs:element minOccurs="0" name="Street" type="xs:string"/>
<xs:element minOccurs="0" name="City" type="xs:string"/>
<xs:element minOccurs="0" name="PostalCode" type="xs:string"/>
<xs:element minOccurs="0" name="Country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="CarType">
<xs:sequence>
<xs:element name="Brand" type="xs:string"/>
<xs:element minOccurs="0" name="VIN" type="xs:string"/>
<xs:element minOccurs="0" name="Model" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="QuickFeedbackEventType">
<xs:sequence>
<xs:element minOccurs="0" name="StudyId" type="xs:integer"/>
<xs:element minOccurs="0" name="Period" type="xs:integer"/>
<xs:element minOccurs="0" name="SurveyNumber" type="xs:integer"/>
<xs:element name="Date" type="xs:dateTime"/>
<xs:element name="Type" type="xs:integer"/>
<xs:element name="Customer">
<xs:complexType>
<xs:complexContent>
<xs:extension base="tns:QuickFeedbackCustomerType">
<xs:sequence>
<xs:element minOccurs="0" name="ID" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Car" type="tns:CarType"/>
<xs:element minOccurs="0" name="Organization" type="tns:OrganizationType"/>
<xs:element name="Importer" type="tns:ImporterType"/>
<xs:element name="ManualImport" type="xs:integer"/>
</xs:sequence>
<xs:attribute name="Number" type="xs:int" use="required"/>
</xs:complexType>
<xs:complexType name="OrganizationType">
<xs:sequence>
<xs:element minOccurs="0" name="Country" type="xs:string"/>
<xs:element minOccurs="0" name="Code" type="xs:string"/>
<xs:element minOccurs="0" name="EngineerCode" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ImporterType">
<xs:sequence>
<xs:element name="BID" type="xs:string"/>
<xs:element minOccurs="0" name="Country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="QuickFeedbackResultSetType">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="QuickFeedbackResult" type="tns:QuickFeedbackResultType"/>
</xs:sequence>
<xs:attribute name="Count" type="xs:int" use="required"/>
</xs:complexType>
<xs:complexType name="QuickFeedbackResultType">
<xs:sequence>
<xs:element minOccurs="0" name="StudyId" type="xs:integer"/>
<xs:element minOccurs="0" name="Period" type="xs:integer"/>
<xs:element minOccurs="0" name="SurveyNumber" type="xs:integer"/>
<xs:element minOccurs="0" name="DeliveryDate" type="xs:date"/>
<xs:element minOccurs="0" name="EventType" type="xs:integer"/>
<xs:element minOccurs="0" name="ReturnReason" type="xs:integer"/>
<xs:element minOccurs="0" name="QuestionnaireDate" type="xs:date"/>
<xs:element name="Customer" type="tns:CustomerIdType"/>
<xs:element name="BID" type="xs:string"/>
</xs:sequence>
<xs:attribute name="Number" type="xs:int" use="required"/>
</xs:complexType>
<xs:complexType name="CustomerIdType">
<xs:sequence>
<xs:element minOccurs="0" name="ID" type="xs:string"/>
<xs:element minOccurs="0" name="Email" type="xs:string"/>
<xs:element minOccurs="0" name="Phone" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="QuickFeedbackEventSetType">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Event" type="tns:QuickFeedbackEventType"/>
</xs:sequence>
<xs:attribute name="Count" type="xs:int" use="required"/>
</xs:complexType>
</xs:schema>
Unless schema2.xsd imports a third schema or it has something special I think this should work.
Just in case you have any issue with the copied content from schema2, note that now in this combined schema you only have one namespace prefix, and that is xs, you already don't have neither xsd nor ns1.
If you get all this headers right, the rest should give you no trouble since it's only a copy-pasted list of <xs:element> and <xs;complexType>.
Hope it helped.
Btw, what are those 2 asterisks in your wsdl before and after <xsd:schema>?
I am trying to create reusable element declarations for a web service to insert and update. I have the following declarations:
<xs:complexType name="commonEntity">
<xs:sequence>
<xs:element name="id" type="snt-common:id" minOccurs="0"
maxOccurs="1" />
<xs:element name="createdByID" type="snt-common:id"
minOccurs="0" maxOccurs="1" />
<xs:element name="createDate" type="snt-common:dateTime"
minOccurs="0" maxOccurs="1" />
<xs:element name="modifiedByID" type="snt-common:id"
minOccurs="0" maxOccurs="1" />
<xs:element name="modifyDate" type="snt-common:dateTime"
minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="contact">
<xs:complexContent>
<xs:extension base="snt-common:commonEntity">
<xs:sequence>
<xs:element name="firstName" type="snt-common:string255"
minOccurs="0" maxOccurs="1" />
<xs:element name="lastName" type="snt-common:string255"
minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element id="update" name="ContactUpdateRequest">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="snt:contact">
<xs:sequence>
<xs:element name="id" type="snt-common:id" minOccurs="1"
maxOccurs="1" />
<xs:element name="modifyDate" type="snt-common:dateTime"
minOccurs="1" maxOccurs="1" />
<xs:element name="firstName" type="snt-common:string255"
minOccurs="0" maxOccurs="1" />
<xs:element name="lastName" type="snt-common:string255"
minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element id="insert" name="ContactInsertRequest">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="snt:contact">
<xs:sequence>
<xs:element name="firstName" type="snt-common:string255"
minOccurs="0" maxOccurs="1" />
<xs:element name="lastName" type="snt-common:string255"
minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
What I am trying to achieve is to create an insert and an update request, both of which are restrictions of contact. Contact in turn is an extension of commonEntity, which is used for all schemas as a base.
Insert works fine since there are no additional restrictions, but for update we require the id and modifyDate (this is how we enforce versioning) in the request. However, I get the following error when validating the schema:
Error for type '#AnonType_ContactUpdateRequest'. The particle of the type is not a valid restriction of the particle of
the base.
It seems as though I cannot restrict elements in the base element, commonEntity. I have tried reordering without success. Is this a nuance of XSD or am I missing something?
Update:
common.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" targetNamespace="http://predictivesolutions.com/schema/common"
xmlns:snt-common="http://predictivesolutions.com/schema/common"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc" elementFormDefault="qualified"
jaxb:version="2.0">
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings>
<xjc:javaType name="java.util.Calendar" xmlType="xs:dateTime"
adapter="com.ps.snt.ws.util.CalendarDateTimeAdapter" />
<xjc:javaType name="java.util.Calendar" xmlType="xs:date"
adapter="com.ps.snt.ws.util.CalendarDateAdapter" />
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
<!-- Creating this id type to use in the event we need to change to a long,
we can just do it here. -->
<xs:simpleType name="id">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"></xs:minInclusive>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="dateTime">
<xs:restriction base="xs:dateTime">
<!-- 2013-11-06T11:17:17.043-05:00 -->
<xs:pattern value="\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\d[+\-]\d\d:\d\d" />
<!-- 2013-11-06T11:17:17-05:00 -->
<xs:pattern value="\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d[+\-]\d\d:\d\d" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="string255">
<xs:restriction base="xs:string">
<xs:maxLength value="255" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="commonEntity">
<xs:sequence>
<xs:element name="id" type="snt-common:id" minOccurs="0"
maxOccurs="1" />
<xs:element name="createdByID" type="snt-common:id"
minOccurs="0" maxOccurs="1" />
<xs:element name="createDate" type="snt-common:dateTime"
minOccurs="0" maxOccurs="1" />
<xs:element name="modifiedByID" type="snt-common:id"
minOccurs="0" maxOccurs="1" />
<xs:element name="modifyDate" type="snt-common:dateTime"
minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:schema>
contact.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://predictivesolutions.com/schema/v1_1" xmlns:snt="http://predictivesolutions.com/schema/v1_1"
xmlns:snt-common="http://predictivesolutions.com/schema/common"
elementFormDefault="qualified">
<xs:import namespace="http://predictivesolutions.com/schema/common"
schemaLocation="../common.xsd" />
<xs:complexType name="contact">
<xs:complexContent>
<xs:extension base="snt-common:commonEntity">
<xs:sequence>
<xs:element name="firstName" type="snt-common:string255"
minOccurs="0" maxOccurs="1" />
<xs:element name="lastName" type="snt-common:string255"
minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- For transporting data -->
<xs:element id="contact" name="contact" type="snt:contact">
</xs:element>
</xs:schema>
ContactService.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://predictivesolutions.com/schema/v1_1" xmlns:snt="http://predictivesolutions.com/schema/v1_1"
xmlns:snt-common="http://predictivesolutions.com/schema/common"
elementFormDefault="qualified">
<xs:import namespace="http://predictivesolutions.com/schema/common"
schemaLocation="../common.xsd" />
<xs:include schemaLocation="contact.xsd" />
<!-- Request/Response for inserting data -->
<xs:element id="insert" name="ContactInsertRequest">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="snt:contact">
<xs:sequence>
<xs:element name="firstName" type="snt-common:string255"
minOccurs="0" maxOccurs="1" />
<xs:element name="lastName" type="snt-common:string255"
minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- Request/Response for updating data -->
<xs:element id="update" name="ContactUpdateRequest">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="snt:contact">
<xs:sequence>
<xs:element name="id" type="snt-common:id" minOccurs="1"
maxOccurs="1" />
<xs:element name="modifyDate" type="snt-common:dateTime"
minOccurs="1" maxOccurs="1" />
<xs:element name="firstName" type="snt-common:string255"
minOccurs="0" maxOccurs="1" />
<xs:element name="lastName" type="snt-common:string255"
minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:schema>
I want to define a complex type that contains elements that may or may not exist, and also allows for additional undefined elements so I've got something like this:
<xs:complexType name="MyType">
<xs:sequence>
<xs:element name="A" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="B" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="C" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:any minOccurs="0" processContents="skip"/>
</xs:sequence>
</xs:complexType>
I don't want to force the order using <xs:sequence> so I want to change the <xs:sequence> to <xs:all> but then <xs:any> isn't allowed. Is there some way to accomplish this?
To allow any order, use this:
<xs:complexType name="MyType">
<xs:all minOccurs="1" maxOccurs="1">
<xs:element name="A" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="B" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="C" type="xs:float" minOccurs="0" maxOccurs="1" />
</xs:all>
</xs:complexType>
But then, you can't have an <any> inside an <all>.
Nor can you have them both inside one type, either directly or as an extension.