使用soapweb服务时的转换问题
本文关键字:转换 问题 soapweb 服务 使用 | 更新日期: 2023-09-27 18:29:40
我引用了一个名为RemedyInc的web服务。我正试图使用以下c#代码来使用此web服务:
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();
RemedyInc.HelpDesk_Submit_ServiceResponse Response = new RemedyInc.HelpDesk_Submit_ServiceResponse();
RemTicket.AuthenticationInfo = AuthInfo;
RemTicket.Summary = "This is a web service Test";
RemTicket.Last_Name = "Peck";
RemTicket.First_Name = "Kenneth";
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";
}
在我到达RemTicket之前,一切似乎都很好。状态我只是选择了web服务提供的选项之一,但我遇到了这个转换错误。
枚举客户端RemedyInc.StatusType
错误:无法将类型"Client.RemedyInc.StatusType"隐式转换为"Client.RemodyInc.SStatusType[]"
web服务引用如下。
public string HelpDesk_Submit_Service(
Client.RemedyInc.AuthenticationInfo AuthenticationInfo,
string Summary,
string Last_Name,
string First_Name,
System.Nullable<Service_TypeType> Service_Type,
System.Nullable<Reported_SourceType> Reported_Source,
StatusType[] Status,
System.Nullable<UrgencyType>[] Urgency,
System.Nullable<ImpactType>[] Impact,
string Notes,
string TemplateID,
string Action)
HelpDesk_Submit_Service(inValue);
return retVal.Incident_Number;
}
RemTicket.Status是StatusType[]类型
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="urn:HPD_IncidentInterface_Create_WS", Order=32)]
[System.Xml.Serialization.XmlElementAttribute("Status")]
public StatusType[] Status;
如何从web服务提供的列表中选择"新建"并将其传递给RemTicket.Status?
public enum StatusType {
New,
Assigned,
[System.Xml.Serialization.XmlEnumAttribute("In Progress")]
InProgress,
Pending,
Resolved,
Closed,
Cancelled,
}
这应该很简单,但我似乎无法通过正确的"类型"。任何帮助都将不胜感激。
Status是StatusType的数组
RemTicket.Status = new RemedyInc.StatusType[] { RemedyInc.StatusType.New };