如何在c#soap Web服务中将xml属性添加到列表中

如何在c#soap Web服务中将xml属性添加到列表中,c#,web-services,c#-4.0,soap,C#,Web Services,C# 4.0,Soap,如何生成以下XML输出SOAP1.1/SOAP1.2 <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> &l

如何生成以下XML输出SOAP1.1/SOAP1.2

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
 <querySeatResponse xmlns="xxx">
  <querySeatResult>
   <querySeat_status code="int" msg="string">
    <details>
     <detail seat_no="string" available="string" />
     <detail seat_no="string" available="string" />
    </details>
   </querySeat_status>
  </querySeatResult>
 </querySeatResponse>
</soap:Body>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Body>
  <querySeatResponse xmlns="xxx">
   <querySeatResult>
     <querySeat_status code="int" msg="string">
       <details>
         <detail xsi:nil="true" />
         <detail xsi:nil="true" />
       </details>
     </querySeat_status>
   </querySeatResult>
  </querySeatResponse>
 </soap:Body>
</soap:Envelope>

但是我在SOAP 1.1/SOAP 1.2中得到了以下输出

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
 <querySeatResponse xmlns="xxx">
  <querySeatResult>
   <querySeat_status code="int" msg="string">
    <details>
     <detail seat_no="string" available="string" />
     <detail seat_no="string" available="string" />
    </details>
   </querySeat_status>
  </querySeatResult>
 </querySeatResponse>
</soap:Body>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Body>
  <querySeatResponse xmlns="xxx">
   <querySeatResult>
     <querySeat_status code="int" msg="string">
       <details>
         <detail xsi:nil="true" />
         <detail xsi:nil="true" />
       </details>
     </querySeat_status>
   </querySeatResult>
  </querySeatResponse>
 </soap:Body>
</soap:Envelope>

我的源代码如下:

[WebService(命名空间=”http://tempuri.org/")]
[WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)]
公共类abc:System.Web.Services.WebService
{
[网络方法]
[SoapDocumentMethod(“xxx”,RequestNamespace=“xxx”,ResponseNamespace=“xxx”,Use=SoapBindingUse.Literal,ParameterStyle=SoapParameterStyle.Wrapped]
公共查询地址\u主查询地址([XmlAttribute]字符串签名、字符串运算符\u代码、字符串路由\u id、字符串行程\u编号、字符串出发日期、字符串计数器\u发件人、字符串计数器\u收件人、字符串总线\u类型)
{
querysat_Main=新querysat_Main();
querysat_status status=新querysat_status();
querysat_status.detail detail=新querysat_status.detail();
status.code=0;
status.msg=“成功”;
main.querysat_status=状态;
回水总管;
}
}
[可序列化]
[生成代码(“System.Xml”、“xxxx”)]
[XmlType(Namespace=“xxx”)]
[调试步骤至]
[设计分类(“代码”)]
公共类querySeat_Main
{
查询您的状态;
公共查询位于_Main()
{
}
公共查询状态查询状态{get{return status;}set{status=value;}}
}
[可序列化]
[生成代码(“System.Xml”、“xxx”)]
[XmlType(Namespace=“xxx”)]
[调试步骤至]
[设计分类(“代码”)]
[XmlRoot(“querysat_status”,Namespace=“xxx”)]
公共类查询当前状态
{
int代码;
串味精;
公共查询位于_status(){}
[XmlAttribute]
公共int代码{get{return code;}set{code=value;}}
[XmlAttribute]
公共字符串msg{get{return msg;}set{msg=value;}}
[XmlArray(“详细信息”)]
[XmlArrayItem(“细节”)]
公共列表详细信息=新列表();
[可序列化]
[生成代码(“System.Xml”、“xxx”)]
[调试步骤至]
[设计分类(“代码”)]
[XmlRoot(“querysat_status”,Namespace=“xxx”)]
公共类详细信息
{
绳座;
字符串有效;
公共详细信息(){}
[XmlAttribute]
公共字符串seat_no{get{return seat;}set{seat=value;}}
[XmlAttribute]
可用公共字符串{get{return avail;}set{avail=value;}}
}
}
我需要获取详细信息标签必须包含这些座位号和可用属性

像这样

<details>
    <detail seat_no="string" available="string" />
    <detail seat_no="string" available="string" />
 </details>


如果您为detail类正确设置了XmlRoot属性,请与QuerySat_Status的属性交叉验证您是否可以提供一些代码。所以我可以试试