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

XmlArrayItemAttribute is not honored #180

Closed
paleocomburo opened this issue Jan 13, 2019 · 8 comments
Closed

XmlArrayItemAttribute is not honored #180

paleocomburo opened this issue Jan 13, 2019 · 8 comments

Comments

@paleocomburo
Copy link

paleocomburo commented Jan 13, 2019

I'm trying to port an existing .NET Framework WCF service to .NET Core using SOAP Core. Most of it seems to work as-is, which is great! But I just ran into an issue where the original service has an array of strings, but defines the name of the seperate items using an [XmlArryItem] attribute.

I've created a simple test service to illustrate the point.

Consider this Operation Contract:

[ServiceContract(Namespace ="urn:test:1")]
public interface ITestService
{
    [OperationContract]
    TestResult ExecuteFunction(string firstParameter, [XmlArrayItem("item")]string[] parameterArray);
}

And the result object (not important, but for completeness):

public class TestResult
{
    public string Message { get; set; }
}

This services uses the XmlSerializer:

app.UseSoapEndpoint<TestService>("/Test.svc", new BasicHttpBinding(), SoapSerializer.XmlSerializer, false);

The WSDL will look like this (displaying only the relevant part):

<xs:element name="ExecuteFunction">
    <xs:complexType>
        <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="1" name="firstParameter" type="xs:string"/>
            <xs:element minOccurs="0" maxOccurs="1" name="parameterArray" type="tns:ArrayOfString"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:complexType name="ArrayOfString">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" nillable="true" name="string" type="xs:string"/>
    </xs:sequence>
</xs:complexType>
<xs:element name="ArrayOfString" nillable="true" type="tns:ArrayOfString"/>

But with WCF, the WSDL would look like this (displaying only the array):

<xs:complexType name="ArrayOfString">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" nillable="true" name="item" type="xs:string"/>
    </xs:sequence>
</xs:complexType>
<xs:element name="ArrayOfString" nillable="true" type="tns:ArrayOfString"/>

Notice how the "name" of an individual array item is different.

I'll try to see if I can track down the issue, fix it and submit a PR, but I have no idea where to start looking. So any pointers would be appreciated :-)

@kotovaleksandr
Copy link
Member

Hi @comburo! By WCF you mean SoapSerializer.DataContractSerializer?
@andradf Maybe you can help?

@paleocomburo
Copy link
Author

@kotovaleksandr Hi, no, as mentioned in the issue I'm using the XmlSerializer.

@cubidobusinesssolutions
Copy link
Contributor

@kotovaleksandr I think this can be referenced (and closed) in latest Release 0.9.9.5, right?

@cubidobusinesssolutions
Copy link
Contributor

@comburo This should be released and ready for testing ;)

@paleocomburo
Copy link
Author

Cool, thanks!
I see a lot of changes have been made so time to plan a re-evaluation :-)

@paleocomburo
Copy link
Author

I've verified and it now works as expected. Thanks!

cubidobusinesssolutions pushed a commit to cubidobusinesssolutions/SoapCore that referenced this issue Feb 10, 2021
cubidobusinesssolutions pushed a commit to cubidobusinesssolutions/SoapCore that referenced this issue Feb 10, 2021
@Eddenn
Copy link

Eddenn commented Dec 20, 2024

Hello,
I have the exact same issue with SoapCore 1.1.0.51 in a .NET 8 project.

To summary, this code :

[OperationContract]
public Result DeleteEntities(UserToken user,
                             [XmlArray("EntityCodes", IsNullable = true)] 
                             [XmlArrayItem("EntityCode", IsNullable = true)] 
                             List<string> entityCodeList)

result in WSDL :

<xsd:element name="DeleteEntities">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element minOccurs="0" maxOccurs="1" name="user" type="tns:UserToken"/>
      <xsd:element minOccurs="0" maxOccurs="1" name="entityCodeList" nillable="true" type="tns:ArrayOfString"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

instead of :

<xsd:element name="DeleteEntities">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element minOccurs="0" maxOccurs="1" name="user" type="tns:UserToken"/>
      <xsd:element minOccurs="0" maxOccurs="1" name="EntityCodes" nillable="true" type="tns:ArrayOfEntityCode"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

@Eddenn
Copy link

Eddenn commented Dec 20, 2024

I created a new issue here : #1106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants