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

XmlElement is ignored for collections #1069

Closed
Dialecticus opened this issue Jun 19, 2024 · 2 comments
Closed

XmlElement is ignored for collections #1069

Dialecticus opened this issue Jun 19, 2024 · 2 comments
Labels

Comments

@Dialecticus
Copy link

According to this Microsoft page when XmlElement attribute is applied to a collection property the result should be a "flat" sequence. Take this code:

using SoapCore;
using System.Collections.ObjectModel;
using System.ServiceModel;
using System.Xml.Serialization;

internal class Program
{
    private static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);

        builder.Services.AddControllers().AddXmlSerializerFormatters();
        builder.Services.AddSoapCore();
        builder.Services.AddScoped<ITesting, Testing>();

        var app = builder.Build();

        app.UseHttpsRedirection();
        app.UseRouting();
        app.UseAuthorization();
        app.UseEndpoints(endpoints => { endpoints.UseSoapEndpoint<ITesting>("/Testing", new SoapEncoderOptions(), SoapSerializer.XmlSerializer); });
        app.MapControllers();
        app.Run();
    }
}
public class Testing : ITesting
{
    private IWebHostEnvironment Environment;

    public Testing(IWebHostEnvironment _environment)
    {
        Environment = _environment;
    }

    public void Test(ExampleClass someObj)
    {
        throw new NotImplementedException();
    }
}

[ServiceContract(Namespace = "http://example.org/")]
public interface ITesting
{
    [OperationContract]
    public void Test(ExampleClass someObj);
}
[Serializable]
public class ExampleClass
{
    [XmlElement]
    public Collection<string> ExampleProp { get; set; }
}

In WSDL I should see a simple sequence <xs:element minOccurs="0" maxOccurs="unbounded" name="ExampleProp" type="xsd:string" />, but I see ArrayOfString construct instead.

Copy link

This issue is stale because it has been open for 30 days with no activity.

Copy link

github-actions bot commented Aug 3, 2024

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as completed Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant