简体   繁体   English

消费Web服务

[英]Consuming a Web Service

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. 我需要从一个Web服务数据到一个GridView控件,使用Visual Studio 2012的wdls是在这里: https://home-c8.incontact.com/insidews/insidews.asmx我需要的https://login.incontact .com / insidews / insidews.asmx?op = DataDownloadReport_Run方法。

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. 我当前的错误:(ds.readXml(response.toString());异常详细信息:System.NullReferenceException:对象引用未设置为对象的实例。

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. 任何帮助将不胜感激。

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM