11 Replies Latest reply: Aug 15, 2012 11:03 AM by abrock RSS

Web Service, .NET, How to handle a NULL enum value?

Brian Triplett

I am trying to help someone setup a C#.NET application to consume the HPD_IncidentInterface_WS/HelpDesk_QueryList_Service web service.  There are multiple enum fields with this operation, if one of them does not have a value then a NULL value is returned which causes an exception to be thrown.

 

Running the below code throws an exception with this information:  {"Instance validation error: '' is not a valid value for Reported_SourceType."}

 

DEV_HPD_IncidentInterface_WS.

HPD_IncidentInterface_WSService ws = new DEV_HPD_IncidentInterface_WS.HPD_IncidentInterface_WSService();

DEV_HPD_IncidentInterface_WS.

AuthenticationInfo auth = new DEV_HPD_IncidentInterface_WS.AuthenticationInfo();

auth.userName =

"TEST

auth.password =

"WS_DEV";

 

ws.AuthenticationInfoValue = auth;

 

string qualification = "";

 

string startRecord = "";

 

string maxLimit = "2";

DEV_HPD_IncidentInterface_WS.

GetListOutputMapGetListValues[] ExistingValues = ws.HelpDesk_QueryList_Service(qualification, startRecord, maxLimit);

 

Any ideas on how to fix?  Thanks in advance

  • 1. Re: Web Service, .NET, How to handle a NULL enum value?
    Carl Wilson

    Hi,

    you will need to place values in the qualification and startRecord variables.

    Here is a VB.NET code example:

     

              Dim strSQL As String

     

              ' // Declare variables for the HPD_IncidentInterface_WS

     

              Dim AuthenticationInfo_Query As New HPD_IncidentInterface_WS.AuthenticationInfo

     

              Dim HelpDesk_Modify_Query_Service As New HPD_IncidentInterface_WS.HPD_IncidentInterface_WSService

     

              ' // Holds the returned values of the Query to the Help Desk form.

     

              Dim Query_OutputMap() As HPD_IncidentInterface_WS.GetListOutputMapGetListValues

     

              ' // Define Authentication Parameters for Submit and Query/Modify WS

              AuthenticationInfo_Query.userName = "Demo"

              AuthenticationInfo_Query.password = "password"

     

              ' // Pass Authentication Info into Header in WS Query/Modify Call

              HelpDesk_Modify_Query_Service.AuthenticationInfoValue = AuthenticationInfo_Query

     

              strSQL = "'First Name' = " + """Bob"""

     

              ' // Initate the WS Query using above qualification

              Query_OutputMap = HelpDesk_Modify_Query_Service.HelpDesk_QueryList_Service(strSQL, 1, 1)

     

     

    You can use SoapUI to consume the Web Service and identify the required values and query string.

  • 2. Re: Web Service, .NET, How to handle a NULL enum value?
    Brian Triplett

    The following fields are enumerators with the out of the box web Incident web services. Contact_Sensitivity, Impact, Priority, Reported_Source, Service_Type, Status, Status_Reason, Urgency, VIP.  In the Remedy application one of those fields will not necessarily have a value, for example Reported_Source is not a required field.  Since the enum field is blank it returns a blank value in C#.  C# does not know how to handle it since the enum list does not have a blank value.

    Here is the auto-populated enum information, a blank value is not an option causing the exception to be thrown:

     

    [System.CodeDom.Compiler.

    GeneratedCodeAttribute("System.Xml", "2.0.50727.3053")]

    [System.

    SerializableAttribute()]

    [System.Xml.Serialization.

    XmlTypeAttribute(Namespace="urn:HPD_IncidentInterface_WS")]

     

    public enum Reported_SourceType {

     

     

    /// <remarks/>

    [System.Xml.Serialization.

    XmlEnumAttribute("Direct Input")]

    DirectInput,

     

     

    /// <remarks/>

    Email,

     

     

    /// <remarks/>

    [System.Xml.Serialization.

    XmlEnumAttribute("External Escalation")]

    ExternalEscalation,

     

     

    /// <remarks/>

    Fax,

     

     

    /// <remarks/>

    [System.Xml.Serialization.

    XmlEnumAttribute("Self Service")]

    SelfService,

     

     

    /// <remarks/>

    [System.Xml.Serialization.

    XmlEnumAttribute("Systems Management")]

    SystemsManagement,

     

     

    /// <remarks/>

    Phone,

     

     

    /// <remarks/>

    [System.Xml.Serialization.

    XmlEnumAttribute("Voice Mail")]

    VoiceMail,

     

     

    /// <remarks/>

    [System.Xml.Serialization.

    XmlEnumAttribute("Walk In")]

    WalkIn,

     

     

    /// <remarks/>

    Web,

     

     

    /// <remarks/>

    Other,

     

     

    /// <remarks/>

    [System.Xml.Serialization.

    XmlEnumAttribute("BMC Impact Manager Event")]

    BMCImpactManagerEvent,

    }

  • 3. Re: Web Service, .NET, How to handle a NULL enum value?
    Kyle Key

    Any advice on this posting? Same issue here. C# calling the web service.

    I am using the default web service that was installed with Incident management.

    Thanks,

    Kyle

  • 4. Re: Web Service, .NET, How to handle a NULL enum value?
    Brian Triplett

    We had to modify the OOB settings.  We changed the properties for the Reported_Source and Status_Reason fields to:

    MaxOccurs = 1

    MinOccurs = 0

    Nillable = true

     

    You might notice another problem.  For string fields, the default settings are for "unbound".  If you open the field just to view the properties then it will reset the field to actually make it unbound.  This changes the string to an array.  For those fields, we change "unbound" to "1". 

     

    Let me know if you have other questions.

    Thanks, Brian

  • 5. Re: Web Service, .NET, How to handle a NULL enum value?
    Kyle Key

    Sorry, Very much a newbie to Remedy. OOB settings?


  • 6. Re: Web Service, .NET, How to handle a NULL enum value?
    Brian Triplett

    OOB = Out Of Box

    Remedy Developer Studio will need to be used to update the HPD_IncidentInterface_WS web service.

  • 7. Re: Web Service, .NET, How to handle a NULL enum value?
    Kyle Key

    Thank you. I will look into that.

  • 8. Re: Web Service, .NET, How to handle a NULL enum value?
    Kyle Key

    Thanks for the push in the right direction. For anybody else following this thread I used the Remedy Administrator

    to make the changes above, so looks like there are at least 2 valid paths to accomplish this.

    thanks again.

    Kyle

  • 9. Re: Web Service, .NET, How to handle a NULL enum value?
    Brian Triplett

    Remedy Administrator was replaced with Remedy 7.5, it now uses Remedy Developer Studio. 

  • 10. Re: Web Service, .NET, How to handle a NULL enum value?
    Mohamed Abdeen

    any one can please send the final steps to solve the problem, i have the same problem and i can't solve it

  • 11. Re: Web Service, .NET, How to handle a NULL enum value?
    abrock

    NOTE: I deleted the duplicate postings on this thread.    

     

    Anne