header property/field 必须是 SoapHeader 类型或派生类型,或者是 SoapHeader 或 SoapUnknownHeader 的数组
The header property/field must be of type SoapHeader or a derived type, or an array of SoapHeader or SoapUnknownHeader
using System.Data;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace MyServices
{
/// <summary>
/// Summary description for Enroll
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Enroll : WebService
{
public Credentials Credentials = new Credentials();
[WebMethod(Description = "This method call will insert a public note with the given comments", EnableSession = false)]
[SoapHeader("Credentials")]
public bool ActivityInsert(int docId, string activityType, string comments, string userNameOn247, string userNameEt)
{
return EnrollBl.ActivityInsertBl(docId, activityType, ref comments, userNameOn247, userNameEt, this.Credentials);
}
[WebMethod(Description = "This method call will insert the enrollment document into the database and return the relevant document id.", EnableSession = false)]
[SoapHeader("Credentials")]
public EnrollResponse EnrollmentInsert(Enrollment enrollmentRequest)
{
return EnrollBl.EnrollmentInsertBl(enrollmentRequest, this.Credentials);
}
[WebMethod(Description = "This method call will retrieve the pdf file based on document id", EnableSession = false)]
[SoapHeader("Credentials")]
public object EnrollmentFile(int documentId)
{
return EnrollBl.EnrollmentFileBl(documentId, this.Credentials);
}
[WebMethod(Description = "This method call will update the enrollment document status from Ready to Approved and also insert a public note with the given comments", EnableSession = false)]
[SoapHeader("Credentials")]
public bool EnrollmentUpdate(int docId, string activityType, string comments, string userNameEt, string userNameOn247)
{
return EnrollBl.EnrollmentUpdateBl(docId, activityType, ref comments, userNameOn247, userNameEt, this.Credentials);
}
[WebMethod(Description = "This method call will retrieve the history details for the given document id", EnableSession = false)]
[SoapHeader("Credentials")]
public DataTable EnrollmentHistory(int documentId)
{
return EnrollBl.EnrollmentHistoryBl(documentId, this.Credentials);
}
[WebMethod(Description = "This method call will retrieve all the documents that match the search criteria", EnableSession = false)]
[SoapHeader("Credentials")]
public DataTable EnrollmentSearch(SearchEnrollment searchParams)
{
return EnrollBl.EnrollmentSearchBl(searchParams, this.Credentials);
}
[WebMethod(Description = "This method call retrieves all the active form types as dataset", EnableSession = false)]
[SoapHeader("Credentials")]
public DataSet FormList()
{
return EnrollBl.FormListBl(this.Credentials);
}
[WebMethod(Description = "This method call retrieves all document statuses as dataset", EnableSession = false)]
[SoapHeader("Credentials")]
public DataSet StatusList()
{
return EnrollBl.StatusListBl(this.Credentials);
}
}
}
我创建了上面的 Web 服务,并向该服务添加了 soap header 属性,但出现以下错误
headerproperty/fieldEnroll.Credentials必须是 SoapHeader 类型或派生类型,或者是 SoapHeader 或 SoapUnknownHeader 数组。
问题描述:当前网络请求执行过程中出现未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:System.Exception:header property/field Enroll.Credentials 必须是 SoapHeader 类型或派生类型,或者是 SoapHeader 或 SoapUnknownHeader 数组。
我将 SOAP Header class 属性继承到凭据 class 然后 Web 服务正常工作。
using System.Data;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace MyServices
{
/// <summary>
/// Summary description for Enroll
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Enroll : WebService
{
public Credentials Credentials = new Credentials();
[WebMethod(Description = "This method call will insert a public note with the given comments", EnableSession = false)]
[SoapHeader("Credentials")]
public bool ActivityInsert(int docId, string activityType, string comments, string userNameOn247, string userNameEt)
{
return EnrollBl.ActivityInsertBl(docId, activityType, ref comments, userNameOn247, userNameEt, this.Credentials);
}
[WebMethod(Description = "This method call will insert the enrollment document into the database and return the relevant document id.", EnableSession = false)]
[SoapHeader("Credentials")]
public EnrollResponse EnrollmentInsert(Enrollment enrollmentRequest)
{
return EnrollBl.EnrollmentInsertBl(enrollmentRequest, this.Credentials);
}
[WebMethod(Description = "This method call will retrieve the pdf file based on document id", EnableSession = false)]
[SoapHeader("Credentials")]
public object EnrollmentFile(int documentId)
{
return EnrollBl.EnrollmentFileBl(documentId, this.Credentials);
}
[WebMethod(Description = "This method call will update the enrollment document status from Ready to Approved and also insert a public note with the given comments", EnableSession = false)]
[SoapHeader("Credentials")]
public bool EnrollmentUpdate(int docId, string activityType, string comments, string userNameEt, string userNameOn247)
{
return EnrollBl.EnrollmentUpdateBl(docId, activityType, ref comments, userNameOn247, userNameEt, this.Credentials);
}
[WebMethod(Description = "This method call will retrieve the history details for the given document id", EnableSession = false)]
[SoapHeader("Credentials")]
public DataTable EnrollmentHistory(int documentId)
{
return EnrollBl.EnrollmentHistoryBl(documentId, this.Credentials);
}
[WebMethod(Description = "This method call will retrieve all the documents that match the search criteria", EnableSession = false)]
[SoapHeader("Credentials")]
public DataTable EnrollmentSearch(SearchEnrollment searchParams)
{
return EnrollBl.EnrollmentSearchBl(searchParams, this.Credentials);
}
[WebMethod(Description = "This method call retrieves all the active form types as dataset", EnableSession = false)]
[SoapHeader("Credentials")]
public DataSet FormList()
{
return EnrollBl.FormListBl(this.Credentials);
}
[WebMethod(Description = "This method call retrieves all document statuses as dataset", EnableSession = false)]
[SoapHeader("Credentials")]
public DataSet StatusList()
{
return EnrollBl.StatusListBl(this.Credentials);
}
}
}
我创建了上面的 Web 服务,并向该服务添加了 soap header 属性,但出现以下错误
headerproperty/fieldEnroll.Credentials必须是 SoapHeader 类型或派生类型,或者是 SoapHeader 或 SoapUnknownHeader 数组。
问题描述:当前网络请求执行过程中出现未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:System.Exception:header property/field Enroll.Credentials 必须是 SoapHeader 类型或派生类型,或者是 SoapHeader 或 SoapUnknownHeader 数组。
我将 SOAP Header class 属性继承到凭据 class 然后 Web 服务正常工作。