Workflow Soluiton

 View Only
  • 1.  Webservice Generator with invalid enumerator

    Posted Feb 01, 2011 05:17 PM

    I'm trying to create a web service integration library.   I'm able to create the web service but when I use it I get an error message.  "Instance validation error: 'E-mail' is not a valid value for Oncall_Notify_ByType." 

    Below is a portion of the webservice XML.

    <xsd:element name="GetResponse" type="s0:GetOutputMap" />
        <xsd:complexType name="GetOutputMap">
            <xsd:sequence>
           <xsd:element name="Record_Id" type="xsd:string" />
           <xsd:element name="Manager" type="xsd:string" />
           <xsd:element name="Manager_ID" type="xsd:string" />
           <xsd:element name="Oncall_Person" type="xsd:string" />
           <xsd:element name="Oncall_ID" type="xsd:string" />
           <xsd:element name="Oncall_Notify_By" type="s0:Oncall_Notify_ByType" />
           <xsd:element name="Prefix" type="xsd:string" />
           <xsd:element name="Status" type="s0:StatusType" />
           <xsd:element name="Support_Area" type="xsd:string" />
          </xsd:sequence>
      </xsd:complexType>
     
    <xsd:simpleType name="Oncall_Notify_ByType">
        <xsd:restriction base="xsd:string">
           <xsd:enumeration value="None" />
           <xsd:enumeration value="Phone" />
           <xsd:enumeration value="E-mail" />
           <xsd:enumeration value="Printer" />
           <xsd:enumeration value="Beeper" />
            <xsd:enumeration value="Alpha Pager" />
        </xsd:restriction>
        </xsd:simpleType>
    Looking into the problem further I traced it back to the C# source code.
     
    public enum Oncall_Notify_ByType
    {
            None,
            Phone,
            Email,
            Printer,
            Beeper,
            AlphaPager
    }
    Basically, hyphens are not allowed in enums so the hyphen is stripped out of, "E-mail" but then when the web service responds with "E-mail" the string cannot be cast into a member of the enum.
     
    Has anyone run into this?  Whats the best practice for resolving this?
     
    Thanks,
    Ryan


  • 2.  RE: Webservice Generator with invalid enumerator

    Posted Feb 03, 2011 03:17 PM

    Ask the author of the webservice to use underscores or a camel-cased EMail as the enum instead of the one with the hyphen?

    Failing that, you basically have to mark up the C# to remove/correct any reference to the enum, as that's not a valid identifier in C#