簡體   English   中英

WCF - 如何在請求中創建多個具有相同名稱的元素

[英]WCF - how to create multiple elements in request with same name

我需要實現 Web 服務以在客戶端創建請求。 多個 Esc 元素應該與其他不同的元素處於同一級別。 如果我使用 list,它會在 Escs 下創建元素列表。 任何幫助表示贊賞。

XML 請求

嘗試這個

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            XNamespace ns = "abc";
            XElement request = new XElement(ns + "Request", new object[] {
               new XElement(ns + "Cont"),
               new XElement(ns + "Lea"),
               new XElement(ns + "Deal"),
               new XElement(ns + "Esc"),
               new XElement(ns + "Esc"),
               new XElement(ns + "Esc"),
               new XElement(ns + "Esc"),
               new XElement(ns + "Esc"),
               new XElement(ns + "Part"),
               new XElement(ns + "Veh")
            });
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM