Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sidec15 opened this issue Nov 13, 2024 · 0 comments
Labels
tooling An issues related to any tool shipped from this repo.

Comments

@sidec15
Copy link

sidec15 commented Nov 13, 2024

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

@HongGit HongGit added the tooling An issues related to any tool shipped from this repo. label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling An issues related to any tool shipped from this repo.
Projects
None yet
Development

No branches or pull requests

2 participants