如何在c#中将列表数组参数传递给web服务
本文关键字:参数传递 数组 web 服务 列表 | 更新日期: 2023-09-27 18:28:33
我正试图使用BMC Remedy 7.6.04中创建Remedy Incident的web服务。其中一些参数是数组,您可以从中选择要发送回web服务的值,例如Status。当我选择StatusType、UrgencyType和ImpactType时,我会收到以下错误。以下是状态类型的错误:
无法将类型"Client.RemedyInc.StatusType"隐式转换为'Client.RemedyInc.StatusType[]'
状态在reference.cs中枚举如下:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.233")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:HPD_IncidentInterface_Create_WS")]
public enum StatusType {
/// <remarks/>
New,
/// <remarks/>
Assigned,
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("In Progress")]
InProgress,
/// <remarks/>
Pending,
/// <remarks/>
Resolved,
/// <remarks/>
Closed,
/// <remarks/>
Cancelled,
}
和:
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="urn:HPD_IncidentInterface_Create_WS", Order=32)]
[System.Xml.Serialization.XmlElementAttribute("Status")]
public StatusType[] Status;
这是我的代码示例:
protected void ToRemedy_Click(object sender, EventArgs e)
{
RemedyInc.AuthenticationInfo AuthInfo = new RemedyInc.AuthenticationInfo();
AuthInfo.userName = "User";
AuthInfo.password = "Password";
RemedyInc.HelpDesk_Submit_ServiceRequest RemTicket = new RemedyInc.HelpDesk_Submit_ServiceRequest();
RemTicket.AuthenticationInfo = AuthInfo;
RemTicket.Summary = "This is a web service Test";
RemTicket.Last_Name = "LName";
RemTicket.First_Name = "FName";
RemTicket.Service_Type = RemedyInc.Service_TypeType.UserServiceRequest;
RemTicket.Reported_Source = RemedyInc.Reported_SourceType.SelfService;
RemTicket.Status = RemedyInc.StatusType.New;
RemTicket.Urgency = RemedyInc.UrgencyType.Item4Low;
RemTicket.Impact = RemedyInc.ImpactType.Item4MinorLocalized;
RemTicket.Notes = "This is a web service test";
RemTicket.TemplateID = "AGGAAHHLITMRAAMBGOJWBIN45LBV62";
RemTicket.Action = "CREATE";
}
如有任何帮助,我们将不胜感激。Ken
是否应该将Status
声明为数组?这似乎就是例外,因为您不能将StatusType
分配给类型StatusType[]
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="urn:HPD_IncidentInterface_Create_WS", Order=32)]
[System.Xml.Serialization.XmlElementAttribute("Status")]
public StatusType Status; // Declared as StatusType instead of StatusType[]
如果声明是正确的,那么您可能只需要调用代码将New值分配为数组。
RemTicket.Status = new StatusType[] { RemedyInc.StatusType.New };