Skip to content

dotnet-svcutil does not generate attributes from nested attribute groups in WSDL #5686

Open
@sidec15

Description

@sidec15

Describe the bug
When using dotnet-svcutil to generate a .NET client for a SOAP service defined by a WSDL that includes nested attributeGroup references, the generated client code does not contain the attributes from the nested attributeGroup. Only attributes from the outer attributeGroup are included, leaving the client incomplete and missing necessary attributes.

To Reproduce
Steps to reproduce the behavior:

  1. Use the following WSDL to define a simple SOAP service with nested attribute groups:
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:tns="http://example.com/simpleService"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             targetNamespace="http://example.com/simpleService">

    <types>
        <xsd:schema targetNamespace="http://example.com/simpleService">
            
            <!-- Attribute Groups -->
            <xsd:attributeGroup name="InnerAttributes">
                <xsd:attribute name="Attribute1" type="xsd:string"/>
                <xsd:attribute name="Attribute2" type="xsd:int"/>
            </xsd:attributeGroup>
            
            <xsd:attributeGroup name="OuterAttributes">
                <xsd:attributeGroup ref="tns:InnerAttributes"/>
                <xsd:attribute name="AdditionalAttribute" type="xsd:string"/>
            </xsd:attributeGroup>
            
            <!-- Request Object -->
            <xsd:element name="SimpleRequest">
                <xsd:complexType>
                    <xsd:attributeGroup ref="tns:OuterAttributes"/>
                </xsd:complexType>
            </xsd:element>

            <!-- Response Object -->
            <xsd:element name="SimpleResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="ResponseMessage" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </types>

    <message name="SimpleRequestMessage">
        <part name="parameters" element="tns:SimpleRequest"/>
    </message>
    <message name="SimpleResponseMessage">
        <part name="parameters" element="tns:SimpleResponse"/>
    </message>

    <portType name="SimpleServicePortType">
        <operation name="ProcessSimpleRequest">
            <input message="tns:SimpleRequestMessage"/>
            <output message="tns:SimpleResponseMessage"/>
        </operation>
    </portType>

    <binding name="SimpleServiceBinding" type="tns:SimpleServicePortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="ProcessSimpleRequest">
            <soap:operation soapAction="http://example.com/simpleService/ProcessSimpleRequest"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>

    <service name="SimpleService">
        <port name="SimpleServicePort" binding="tns:SimpleServiceBinding">
            <soap:address location="http://localhost/SimpleService"/>
        </port>
    </service>

</definitions>
  1. Run the following dotnet-svcutil command to generate the client code:
dotnet-svcutil "simple-service.wsdl" \
  --outputFile "SoapService.cs" \
  --targetFramework net8.0 -v Debug \
  --namespace *,"foo" \
  -ser XmlSerializer \
  -wr
  1. Observe that the generated SimpleRequest class does not include Attribute1 and Attribute2 from InnerAttributes. Only AdditionalAttribute from OuterAttributes is generated.
  2. Example of generated code:
public partial class SimpleRequest
{
    private string additionalAttributeField;
    
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string AdditionalAttribute
    {
        get { return this.additionalAttributeField; }
        set { this.additionalAttributeField = value; }
    }
}

Expected behaviour
I expected dotnet-svcutil to generate SimpleRequest with all attributes from both OuterAttributes and the nested InnerAttributes, as defined in the WSDL. Specifically, SimpleRequest should include Attribute1 and Attribute2 in addition to AdditionalAttribute.

Additional context
This issue affects applications relying on nested attributeGroup structures, as such grouping is often used in complex XML schemas. The missing attributes result in incomplete client data structures, which leads to issues when interacting with the SOAP service.

Environment:
dotnet-svcutil version: 2.1.0
.NET SDK version: net8.0

Metadata

Metadata

Assignees

Labels

toolingAn issues related to any tool shipped from this repo.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions