0

I have been working on this for two weeks and cannot quite get the answer.

I need to get data from a web service into a gridview, using Visual Studio 2012. The wdls is here: https://home-c8.incontact.com/insidews/insidews.asmx I need the https://login.incontact.com/insidews/insidews.asmx?op=DataDownloadReport_Run method.

What i have so far is:

//created service reference called icContact

//Created Credentials
icContactSR.inCredentials cr = new icContactSR.inCredentials();
cr.busNo = xxxxxx;
cr.password = "xxxxxxx";
DateTime startDate = new DateTime(2013, 12, 27, 8, 00, 00);
DateTime endDate = new DateTime(2013, 12, 27, 9, 00, 00);

//create request
icContactSR.DataDownloadReport_RunRequest request = 
    new `DataDownloadReport_RunRequest(cr, reportnumber, startDate, endDate);`

//get response
icContactSR.DataDownloadReport_RunResponse response = new    
        icContactSR.DataDownloadReport_RunResponse();


//fill dataset with response
DataSet ds = (DataSet)response.DataDownloadReport_RunResult;



GridView1.DataSource = ds.ReadXml(response.ToString());
 GridView1.DataBind();

My current error: (ds.readXml(response.toString()); Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

I feel like i am soo close to finding the answer, but I dont know if it is simply not knowing how to fill the dataset from the response or if i am getting the response back at all. Every time I run it, my dataset is null. any help will be appreciated.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
wesreitz
  • 79
  • 6
  • 1
    Is anything being returned by `response`? – B-M Jan 08 '14 at 15:38
  • Set a breakpoint under your `//fill dataset` and inspect `response`. – CodeCaster Jan 08 '14 at 15:43
  • Check if `ds != null` – abto Jan 08 '14 at 15:44
  • 2
    Welcome to Stack Overflow! ASMX is a legacy technology, and should not be used for new development. WCF or ASP.NET Web API should be used for all new development of web service clients and servers. One hint: Microsoft has retired the [ASMX Forum](http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/threads) on MSDN. – John Saunders Jan 08 '14 at 15:46
  • 1
    I don't have time to fix this for you, but you're never calling the service. Also, you can use a Service Reference, even for an ASMX service. See "[How to Consume a Web Service](http://johnwsaunders3.wordpress.com/2009/05/17/how-to-consume-a-web-service/)". – John Saunders Jan 08 '14 at 15:47
  • nothing is being returned by the response. At least that is what I think. because it is always null. also, I don't have a choice, because I am only the consumer of the service. Maybe, I need someone to show me the line of code that actually calls the service? – wesreitz Jan 08 '14 at 16:53
  • John Saunders link helped me solve the problem. funny thing- I looked at his tutorial over a week ago. Here is what I did to finally make it work. //created service reference called icContact //Created Credentials icContactSR.inCredentials cr = new icContactSR.inCredentials(); using (var svc = new icContactSR.inSideWSSoapClient()) { var request = svc.DataDownloadReport_Run(cr, reportnumber, startDate, endDate); GridView1.DataSource = request; GridView1.DataBind(); } – wesreitz Jan 08 '14 at 17:32

1 Answers1

0

You can try this

// object to InContact Web Service reference
var client = new icContactSR.inSideWS()
{
    inCredentialsValue = new icContactSR.inCredentials()
    {
        password = ******,
        busNo = ******,
        timeZoneName = "UTC"
    }
};

DateTime startDate = new DateTime(2013, 12, 27, 8, 00, 00);
DateTime endDate = new DateTime(2013, 12, 27, 9, 00, 00);

DataSet dsCallDetails = client.DataDownloadReport_Run(report_number, startDate.ToUniversalTime(), endDate.ToUniversalTime());

GridView1.DataSource = dsCallDetails.Tables[0];
GridView1.DataBind();
Atta H.
  • 661
  • 5
  • 11