我有两个类,一个实现Func
,另一个具有IXmlSerializable
属性:
DataContract
然后我有服务接口
public class Foo : IXmlSerializable
{
public XmlSchema GetSchema()
{
return null;
}
public void ReadXml(XmlReader reader)
{
reader.MoveToContent();
XElement element = (XElement)XNode.ReadFrom(reader);
if (element.Element("Foo") != null)
element = element.Element("Foo");
Property = Convert.ToInt32(element.Element("Property").Value);
}
public void WriteXml(XmlWriter writer)
{
var element = new XElement("Foo");
element.Add(new XElement("Property", Property));
element.WriteTo(writer);
}
public int Property { get; set; }
}
[DataContract]
public class Bar
{
[DataMember]
public int Property { get; set; }
}
其实施方式为:
[ServiceContract]
public interface IFooBarService
{
[OperationContract]
void TestFoo(Foo toTest);
[OperationContract]
void TestListFoo(Foo[] toTest);
[OperationContract]
void TestBar(Bar toTest);
[OperationContract]
void TestListBar(Bar[] toTest);
}
SOAP UI生成了调用服务所需的xml。一切正常,除了调用public class FooBarService : IFooBarService
{
public void TestFoo(Foo toTest)
{
var a = toTest.Property;
}
public void TestListFoo(Foo[] toTest)
{
foreach (var item in toTest)
{
var x = item.Property;
}
}
public void TestBar(Bar toTest)
{
var a = toTest.Property;
}
public void TestListBar(Bar[] toTest)
{
foreach (var item in toTest)
{
var x = item.Property;
}
}
}
,我收到一个空数组
TestListFoo
我错过了什么?有可能实现我的需要吗?
如果没有,我如何将<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:com="http://schemas.datacontract.org/2004/07/Com.Panotec.Remote.Core.WebService" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<soapenv:Header/>
<soapenv:Body>
<tem:TestListFoo>
<tem:toTest>
<Foo>
<Property>1</Property>
</Foo>
<Foo>
<Property>1</Property>
</Foo>
<Foo>
<Property>1</Property>
</Foo>
<Foo>
<Property>1</Property>
</Foo>
</tem:toTest>
</tem:TestListFoo>
</soapenv:Body>
</soapenv:Envelope>
属性添加到实现DataContract
的类?
由于