I have a .NET 2.0 .asmx web service that looks something like this:
[WebMethod]
[return: XmlArray("FileInformations"), XmlArrayItem("FileInformation")]
public FileInformation[] GetFileInformation(
[XmlElement("Path")] string path)
When I try to call this web service from a silverlight windows phone 7 app (beta). I get an InvalidOperationException with an inner InvalidCastException but no further details.
This same service works perfectly when called by a desktop WCF client.
The silverlight proxy generated looks like this:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="GetFileInformationResponse", WrapperNamespace="http://example.com", IsWrapped=true)]
public partial class GetFileInformation {
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://example.com", Order=0)]
[System.Xml.Serialization.XmlArrayItemAttribute("FileInformation")]
public FileInformation[] FileInformation;
I noticed that it lacked an XmlArrayAttribute definition, but it didn't change anything even when I did add it explicitly.
For reference, the actual XML response looks like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<FileInformationResponse xmlns="http://example.com">
<FileInformations>
<FileInformation
fileName="foo.txt" />
</FileInformations>
</GetFileInformations>
</soap:Body>
</soap:Envelope>
What am I doing wrong?