客户发现响应内容类型为"但是预期' text / xml'请求因空响应而失败

时间:2014-07-31 11:23:28

标签: c# web-services wcf

我在Windows应用程序中使用了Web服务,当传递请求以获取响应时出现错误。

我已使用WSE 2.0传递凭据。

public string GetResponse(string sPersonnelAreaCode, string sCompanyCode)
{
    try
    {
        WebReference.RIL_STAR_HCM_QueryEmployeeDetails_serviceagent objService1 = new WebReference.RIL_STAR_HCM_QueryEmployeeDetails_serviceagent();
        WebReference.fetchEmployeeListRequestEmployeeList[] objReqs = new WebReference.fetchEmployeeListRequestEmployeeList[1];
        WebReference.fetchEmployeeListRequestEmployeeList objReq1 = new WebReference.fetchEmployeeListRequestEmployeeList();

        WebReference.fetchEmployeeListResponseEmployeeList[] objResponse = new WebReference.fetchEmployeeListResponseEmployeeList[0];
        DataSet dsresult = new DataSet();
        objReq1.PersonnelAreaCode = sPersonnelAreaCode;
        objReq1.CompanyCode = sCompanyCode.ToString();

        UsernameToken token = new UsernameToken("***", "***", PasswordOption.SendPlainText);
        objService1.RequestSoapContext.Security.Tokens.Add(token);
        objReqs[0] = objReq1;
        //In the below line getting that error
        objResponse = objService1.fetchEmployeeList(objReqs);
    }
}

有人可以帮助我吗?

2 个答案:

答案 0 :(得分:2)

尝试设置ContentType

objReq.ContentType = "text/xml";

假设您正在使用HttpWebRequest ..

答案 1 :(得分:1)

当报表服务器路径不正确时,通常会出现此类错误。仔细检查ReportServerUrl

另请参阅Report viewer Error message "client found response content type of '' but expected 'text xml' The request failed with an empty response."