我想使用 XML 属性而不是 xmlrequest 和 xmlresponse 中的元素,我实现了 IXmlSerializable 如下:
public partial class Id : IXmlSerializable
{
/// <remarks/>
[XmlAttribute]
public string lmsId;
/// <remarks/>
[XmlAttribute]
public string unitId;
/// <remarks/>
[XmlAttribute]
public string lmsPresId;
/// <remarks/>
[XmlAttribute]
public string callId;
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
public void ReadXml(System.Xml.XmlReader reader)
{
//implement if remote callers are going to pass your object in
}
public void WriteXml(System.Xml.XmlWriter writer)
{
writer.WriteAttributeString("lmsId", lmsId.ToString());
writer.WriteAttributeString("unitId", unitId.ToString());
writer.WriteAttributeString("lmsPresId", lmsPresId.ToString());
writer.WriteAttributeString("callId", callId.ToString());
}
}
但我的服务帮助显示请求和响应为未知
我什至尝试了 XmlSerializerFormat
[System.ServiceModel.MessageContract]
public partial class Id
{
/// <remarks/>
[XmlAttribute, MessageBodyMember]
public string lmsId;
/// <remarks/>
[XmlAttribute, MessageBodyMember]
public string unitId;
/// <remarks/>
[XmlAttribute, MessageBodyMember]
public string lmsPresId;
/// <remarks/>
[XmlAttribute, MessageBodyMember]
public string callId;
}
然后我将 xml 中的所有内容作为 xmlElements 而不是 XmlAttributes 但我将所有数据作为元素而不是 Xmlattributes 获取。