我想在我的SOAP响应中添加一个xml属性。
给出以下代码:
using System.Collections.Generic;
[assembly: System.Runtime.Serialization.ContractNamespaceAttribute("http://www.opengis.net/ows/2.0", ClrNamespace = "MyNameSpace.OWS")]
namespace MyNameSpace.OWS
{
public class ExceptionReport
{
public List<OWS.Exception> Exceptions;
public static string version = "1.0.0";
public ExceptionReport()
{
Exceptions = new List<OWS.Exception>();
}
}
public class Exception
{
public string ExceptionText;
public string exceptionCode;
public Exception() {}
}
}
我必须添加到上面的代码中,以便以下响应显示:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
...
<ExceptionReport xmlns="http://www.opengis.net/ows/2.0" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0">
...
</s:Body>
</s:Envelope>
Intead of this(注意ExceptionReport元素上没有版本属性):
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
...
<ExceptionReport xmlns="http://www.opengis.net/ows/2.0" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
...
</s:Body>
</s:Envelope>