【问题标题】:Client found response content type of " but expected 'text/xml' The request failed with an empty response客户端发现响应内容类型为 " 但预期为 'text/xml' 请求失败,响应为空
【发布时间】:2014-07-31 11:23:28
【问题描述】:

我已经在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);
    }
}

谁能帮帮我?

【问题讨论】:

  • 检查this是否有帮助

标签: c# web-services wcf


【解决方案1】:

这种错误通常发生在报表服务器路径不正确时。仔细检查您的ReportServerUrl

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

【讨论】:

    【解决方案2】:

    尝试设置ContentType:

    objReq.ContentType = "text/xml";
    

    假设您使用的是HttpWebRequest..

    【讨论】:

    • 感谢您的回复...ContentType 属性在此 objReq 中不可用
    • objReq的类型是什么?
    • 显然不是 - objReq1.PersonnelAreaCode。从什么时候string 有了PersonnelAreaCode 的属性?
    猜你喜欢
    • 2010-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-06
    • 2011-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多