How to make object property appear in xml attribute
I want to add an xml attribute to my SOAP response.
Given the following code:
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() {}
}
}
What do i have to add to the above code so the following response reads:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:开发者_C百科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 (notice no version attribute on ExceptionReport element):
<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>
精彩评论