none
how to store return values from host application in the client? RRS feed

  • Question

  • The following is the code written in wcf service host application. This application calls the soap webservice within.

    public Jobs_Response Jobs_Get(decimal? refid, decimal? RN, int? WorkID, int? Start, int? ServiceRequestID)

            {

               

                Service1.Jobs_GetResult result;

                using (Service1.Service1WebServiceSoapClient client = new Service1.Service1WebServiceSoapClient())

                {

                    result = client.Jobs_Get(

                        refid,

                        RN,

                        WorkID,

                        Start,

                        ServiceRequestID);

                }

                return Jobs_Response.Parse(result);

            }

    In the client, I want to use the returned values of Client.Jobs_Get

    Proxy.MyServiceClient Client = new MyServiceClient();

    ????????= Client.Jobs_Get(1234, null, null,null, null)

    What should be written in the left hand side of the above? Client.Jobs_Get returns 6 values. I need to capture that values and store it in 6 variables?

    How do I proceed for it? Could anyone please write the sample code.

    Monday, March 24, 2014 11:16 PM

All replies

  • Hi,

    I have created the example in my side, please try to check the following code:

    ServiceReference1.TestService1Client client = new ServiceReference1.TestService1Client();
                ServiceReference1.Jobs_Response Jobs_Response = new ServiceReference1.Jobs_Response();
                Jobs_Response=client.Jobs_Get(1234,null,null,null,null);
                decimal? s1 = Jobs_Response.refid;
                decimal? s2 = Jobs_Response.RN;
                int? s3 = Jobs_Response.Start;
                int? s4 = Jobs_Response.WorkID;
                int? s5 = Jobs_Response.ServiceRequestID;
                Console.WriteLine("refid=" + s1);
                Console.WriteLine("<br/>");
                Console.WriteLine("RN=" + s2);
                Console.WriteLine("<br/>");
                Console.WriteLine("Start="+s3);
                Console.WriteLine("<br/>");
                Console.WriteLine("WorkID=" + s4);
                Console.WriteLine("<br/>");
                Console.WriteLine("ServiceRequestID=" + s5);
                Console.WriteLine("<br/>");
                Console.ReadLine();


    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 25, 2014 3:44 AM
    Moderator
  • I have seen the datacontract of Jobs_Response. It is like the below:

    public class Jobs_Response
    {

    [DataMember]
    public Jobs_ResponseJob[] Jobs {get; set; }

    [DataMember]
    public int RecordCount Jobs {get; set;}

    public static Jobs_Response Parse(Jobs_GetResult input)
    {
    return new Jobs_Response()
    {
    Jobs = (input.Jobs == null)? null : Jobs_ResponseJob.Parse(input.Jobs),
    RecordCount = input.RecordCount
    };

    }

    }

    So, client.Jobs_Get will return Jobs[] and RecordCount. The data member Jobs_ResponseJob in Jobs_Response described above has the following definition:

    public clas Jobs_ResponseJob
    {
    [DataMember]
    public int ServiceRequestID {get; set;}

    [DataMember]
    public int ServiceRequestIDSpecified {get; set;}

    [DataMember]
    public int Premises {get; set;}

    [DataMember]
    public int ScheduledStart {get; set;}

    public static Jobs_ResponseJob Parse(Jobs_GetResultJobsJob input)
    {
    return new Jobs_ResponseJob()
    {
    ServiceRequestID = input.ServiceRequestID,
    ServicRequestIDSpecified = input.ServiceRequestIDSpecified,
    Premises = (input.Premises == null) ? null : CtPremises.Parse(input.Premises),
    ScheduledStart = input.ScheduledStart
    };
    }
    }

    }

    how to assign each of the returned rows of client.Jobs_Get to  ServiceRequestID, ServiceRequestIDSpecified, Premises, ScheduledStart of Jobs_ResponseJob. Once those values are obtained, I need to assign them to local variables


    • Edited by ragavalli Wednesday, March 26, 2014 1:32 PM
    Wednesday, March 26, 2014 11:42 AM