lumeohq / xsd-parser-rs

A xsd/wsdl => rust code generator written in rust
Apache License 2.0
96 stars 34 forks source link

Namespaces screw up generated WSDL operation parameters #134

Open DrChat opened 3 years ago

DrChat commented 3 years ago

Apologies for the name of this issue - I'm still unfamiliar with this library and don't know why this happens, but:

This input:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../../../ver20/util/onvif-wsdl-viewer.xsl"?>

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:s2="http://www.microsoft.com/SoftwareDistribution/Server/IMonitorable"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns:tds="http://www.onvif.org/ver10/device/wsdl" targetNamespace="http://www.onvif.org/ver10/device/wsdl">
    <wsdl:types>
        <s:schema elementFormDefault="qualified" targetNamespace="http://www.microsoft.com/SoftwareDistribution/Server/IMonitorable">
            <s:element name="Ping">
                <s:complexType>
                    <s:sequence>
                        <s:element minOccurs="1" maxOccurs="1" name="pingLevel" type="s:int" />
                    </s:sequence>
                </s:complexType>
            </s:element>
            <s:element name="PingResponse">
                <s:complexType>
                    <s:sequence>
                        <s:element minOccurs="0" maxOccurs="1" name="PingResult" type="s2:MonitoredServicesResponse" />
                    </s:sequence>
                </s:complexType>
            </s:element>
            <s:complexType name="MonitoredServicesResponse">
                <s:sequence>
                    <s:element minOccurs="1" maxOccurs="1" name="SuccessFlag" type="s:boolean" />
                    <s:element minOccurs="1" maxOccurs="1" name="ServicesTime" type="s:dateTime" />
                    <s:element minOccurs="0" maxOccurs="1" name="ServicesName" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" name="ServicesMachine" type="s:string" />
                    <s:element minOccurs="1" maxOccurs="1" name="IsHttps" type="s:boolean" />
                    <s:element minOccurs="0" maxOccurs="1" name="RequestContentType" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" name="ConfigFilePath" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" name="ConfigFileProjectName" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" name="ConfigFileEnvironmentName" type="s:string" />
                    <s:element minOccurs="1" maxOccurs="1" name="ConfigFileLastModifiedTime" type="s:dateTime" />
                    <s:element minOccurs="0" maxOccurs="1" name="ConfigFileVersion" type="s:string" />
                    <s:element minOccurs="1" maxOccurs="1" name="ConfigFileNextExpirationTime" type="s:dateTime" />
                    <s:element minOccurs="1" maxOccurs="1" name="ConfigFileExpirationModuloInMinutes" type="s:int" />
                    <s:element minOccurs="0" maxOccurs="1" name="DatabaseInfo" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" name="CustomInfo" type="s:string" />
                </s:sequence>
            </s:complexType>
        </s:schema>
    </wsdl:types>

    <wsdl:message name="PingSoapIn">
        <wsdl:part name="parameters" element="s2:Ping" />
    </wsdl:message>
    <wsdl:message name="PingSoapOut">
        <wsdl:part name="parameters" element="s2:PingResponse" />
    </wsdl:message>

    <wsdl:portType name="Device">
        <wsdl:operation name="Ping">
            <wsdl:input message="tns:PingSoapIn" />
            <wsdl:output message="tns:PingSoapOut" />
        </wsdl:operation>
    </wsdl:portType>
</wsdl:definitions>

Produces this output:

// Structure definitions omitted for brevity.
pub struct Ping();
pub struct PingResponse();
pub struct MonitoredServicesResponse();

pub async fn ping<T: transport::Transport>(
    transport: &T,
    request: &s2::Ping
) -> Result<s2::PingResponse, transport::Error> {
    transport::request(transport, request).await
}

The parameters to the ping function are generated as-if they belong to an s2 Rust module, but no such module exists. This prevents me from building the generated output without editing it.

The Ping and PingResponse types are qualified as belonging to a namespace aliased as s2 in the input XML.