Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi,

I am trying to get list of data from the Java we service from the c# client.
The web service return the list of items. But through the c# client I can only capture the first element data.

How can I get the list of data from the response?

Here are the auto generated code
Reference.cs
C#
public WindowsFormsApplication1.ServiceReference1.tAddOnDto QueryAvaiableAddOnList(WindowsFormsApplication1.ServiceReference1.tAuthHeader AuthHeader, WindowsFormsApplication1.ServiceReference1.tQueryAvaiableAddOnListBO QueryAvaiableAddOnListBO) {
    WindowsFormsApplication1.ServiceReference1.QueryAvaiableAddOnListRequest inValue = new WindowsFormsApplication1.ServiceReference1.QueryAvaiableAddOnListRequest();
    inValue.AuthHeader = AuthHeader;
    inValue.QueryAvaiableAddOnListBO = QueryAvaiableAddOnListBO;
    WindowsFormsApplication1.ServiceReference1.QueryAvaiableAddOnListResponse retVal = ((WindowsFormsApplication1.ServiceReference1.QueryPortType)(this)).QueryAvaiableAddOnList(inValue);
    return retVal.AddOnDtoList;
}


C#
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://com.company.company/xsd")]
public partial class tAddOnDto : object, System.ComponentModel.INotifyPropertyChanged {
    private string offerCodeField;
    private string offerNameField;
    private string offerTypeField;
    private string effDateField;
    private string expDateField;
    private string autoContinueFlagField;
    private string duplicateFlagField;
    private string commentsField;
    /// <remarks/>    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
    public string OfferCode {
        get {
            return this.offerCodeField;
        }
        set {
            this.offerCodeField = value;
            this.RaisePropertyChanged("OfferCode");
        }
    }


XML response example

XML
<ns:QueryAvaiableAddOnListBOResponse xmlns:ns="http://com.Comapny.companu/xsd">
         <AddOnDtoList>
            <OfferCode>7</OfferCode>
            <OfferName>默认资费计划</OfferName>
            <OfferType>4</OfferType>
            <EffDate>2016-08-08 09:30:35</EffDate>
            <ExpDate/>
            <AutoContinueFlag>N</AutoContinueFlag>
            <DuplicateFlag/>
            <Comments/>
         </AddOnDtoList>
         <AddOnDtoList>
            <OfferCode>794</OfferCode>
            <OfferName>AOC test</OfferName>
            <OfferType>3</OfferType>
            <EffDate>2016-08-30 00:00:00</EffDate>
            <ExpDate/>
            <AutoContinueFlag>N</AutoContinueFlag>
            <DuplicateFlag/>
            <Comments/>
         </AddOnDtoList>
         <AddOnDtoList>
            <OfferCode>ROAM_VAS_CODE</OfferCode>
            <OfferName>ROAM_VAS_CODE</OfferName>
            <OfferType>3</OfferType>
            <EffDate>2016-09-05 00:00:00</EffDate>
            <ExpDate/>
            <AutoContinueFlag>N</AutoContinueFlag>
            <DuplicateFlag/>
            <Comments/>
         </AddOnDtoList>
      </ns:QueryAvaiableAddOnListBOResponse>
   </soapenv:Body>
</soapenv:Envelope>


What I have tried:

here is my coding
C#
ServiceReference1.QueryPortTypeClient ServiceClient = new QueryPortTypeClient();
            ServiceReference1.tAuthHeader hed = new tAuthHeader();
            hed.Username = "?";
            hed.Password = "?";
            ServiceReference1.tQueryAvaiableAddOnListBO addBO = new tQueryAvaiableAddOnListBO();
            addBO.MSISDN = "94722009580";
            tAddOnDto tadd = new tAddOnDto();
            tadd = ServiceClient.QueryAvaiableAddOnList(hed, addBO);
            string a = tadd.OfferName.ToString();
Posted
Updated 14-Sep-16 0:00am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900