XmlArrayItemAttribute is not honored
See original GitHub issueI’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 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
I’ve verified and it now works as expected. Thanks!
Cool, thanks! I see a lot of changes have been made so time to plan a re-evaluation 😃