簡體   English   中英

使用數組C#asp.net消耗Web服務

[英]Consuming webservices with arrays c# asp.net

這是SOAP請求

這是SOAP響應

這是我創建的Struct類

public struct Biller
{

    public string BillerTag { get; set; }
    public string Description { get; set; }
    public string FirstField { get; set; }
    public string FirstFieldFormat { get; set; }
    public string FirstFieldWidth { get; set; }
    public string SecondField { get; set; }
    public string SecondFieldFormat { get; set; }
    public string SecondFieldWidth { get; set; }
    public string ServiceCharge { get; set; }


}

我正在嘗試使用此代碼,但它僅顯示1,並且僅顯示最后一個輸出

[WebMethod(Description = "Retrieves list of available BILLERS for collection as well as other information necessary for the transaction")]
    public Biller GetBillerList(string AccountID, string UserName, string Password)
    {

    ECPNBills.ECPNBillsPaymentService Client = new ECPNBills.ECPNBillsPaymentService();
    ECPNBills.BStruct Str = new ECPNBills.BStruct();


        Biller Bil = new Biller();

        Str = Client.GetBillerList(AccountID, UserName, Password);


        foreach (ECPNBills.BStruct cd in Client.GetBillerList(AccountID, UserName, Password))
        {
            Bil.BillerTag = cd.BillerTag;
            Bil.Description = cd.Description;
            Bil.FirstField = cd.FirstField;
            Bil.FirstFieldFormat = cd.FirstFieldFormat;
            Bil.FirstFieldWidth = cd.FirstFieldWidth;
            Bil.SecondField = cd.SecondField;
            Bil.SecondFieldFormat = cd.SecondFieldFormat;
            Bil.SecondFieldWidth = cd.SecondFieldWidth;
            Bil.ServiceCharge = cd.ServiceCharge;

        }

        return Bil;



    }

我不確定要從BStruct獲取所有項目使用的代碼。

我也在嘗試將webservice消耗到webservice。 預先謝謝你〜

將方法的return type更改為List<Biller>

[WebMethod(Description = "Retrieves list of available BILLERS for collection as well as other information necessary for the transaction")]
public List<Biller> GetBillerList(string AccountID, string UserName, string Password)
{

    ECPNBills.ECPNBillsPaymentService Client = new ECPNBills.ECPNBillsPaymentService();
    ECPNBills.BStruct Str = new ECPNBills.BStruct();


    List<Biller> BilList = new List<Biller>();

    Str = Client.GetBillerList(AccountID, UserName, Password);


    foreach (ECPNBills.BStruct cd in Client.GetBillerList(AccountID, UserName, Password))
    {
        Biller Bil = new Biller();

        Bil.BillerTag = cd.BillerTag;
        Bil.Description = cd.Description;
        Bil.FirstField = cd.FirstField;
        Bil.FirstFieldFormat = cd.FirstFieldFormat;
        Bil.FirstFieldWidth = cd.FirstFieldWidth;
        Bil.SecondField = cd.SecondField;
        Bil.SecondFieldFormat = cd.SecondFieldFormat;
        Bil.SecondFieldWidth = cd.SecondFieldWidth;
        Bil.ServiceCharge = cd.ServiceCharge;

        BilList.Add(Bil);
    }

    return BilList;

}

暫無
暫無

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

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