AddPhone in C# erroring - Invalid content was found starting with element &

Version 1
    This document was generated from CDN thread

    Created by: Chris Bertrand on 10-03-2010 11:26:24 AM
     


    I am trying to add a phone using C# here is a snippet below:

    addPhone = new AddPhoneReq(); 
    XIPPhone phone = new XIPPhone();

    phone.name = tboMac.Text; 
    phone.description = ddlDivision.SelectedValue;
    phone.protocol = "SCCP";
    ...
    ...
    addPhone.newPhone = phone;
    axlService.addPhone(addPhone);
     
    However when getting down to the addphone method i get an error stating:
     
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'protocol'. One of '{"":product, "":productInfo}' is expected.
     
    Does anyone know why this is occuring? I am using V7 and there doesnt appear to be a product field associated to the phone. In the AXLApiService.Cs file that i created there is a property :

    [System.Xml.Serialization.

    XmlElementAttribute("product", typeof(string), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.

    XmlElementAttribute("productInfo", typeof(XProductInfo), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
     
    public object Item  

    get {return this.itemField 
    set {this.itemField = value;}
    }
    which i believe may be the cause.
     
    Any help/ ideas would be great.
     



     

    Subject: RE: AddPhone in C# erroring - Invalid content was found starting with eleme
    Replied by: Chris Bertrand on 10-03-2010 03:46:52 PM
    Just a follow up, i realise that it occurs even if i dont pass any values into the phone variable.
     
    I think this means I'm not completing the Phone variable correctly. It seems like each Item corresponds to a seperate field, and you have to create a seperate object to enclose them, however i am not sure how to do this and what they are.
     
    If anyone has a C# snippet of addPhone working or at least not causing the cvc-complex type.2.4.a: error that they could post that would be very helpful/ or a pointer to somewhere where this is explained??
     

    Subject: RE: AddPhone in C# erroring - Invalid content was found starting with eleme
    Replied by: David Staudt on 10-03-2010 08:53:54 PM
    Some of the fields in addPhone are required, and can't be left out.  For addPhone these are:
     
    - Name
    - Product
    - Model
    - Class
    - Protocol
     
    See the AXL schema documents for this information.

    Subject: RE: AddPhone in C# erroring - Invalid content was found starting with eleme
    Replied by: Chris Bertrand on 11-03-2010 01:34:49 PM
    The AXL Schema is no help at all. To be fair all the documentation is very poor. Product and Model are not set fields when programming in .Net so you have to use a get statement to figure out which ones fit where. In 7.1 iv got
     
    phone.name = mac;
    phone.description = div;
    phone.@class = "Phone";
    phone.protocol = "SCCP";
    phone.protocolSide = "User";
    phone.Item = "Cisco 7961"; Product
    phone.Item1 = "Cisco 7961";Model
    phone.Item3 = "Example"; Device Pool
    phone.Item5 = "Standard Common Phone Profile";  Common Phone Profile
    phone.Item6 = Location
    phone.Item8 = AArCallingSearchSpace
    phone.Item9 = AAR Group
     
    I hope this helps someone. This will succesfully create a phone.

    Subject: RE: AddPhone in C# erroring - Invalid content was found starting with eleme
    Replied by: David Staudt on 11-03-2010 04:57:54 PM
    I believe this 'ItemX' format is due to a limitation in the way the .NET WSDL compiler handles xsd:choice.  You're right in that the easiest way to figure out how .NET maps to these fields is to look at what it returns from a getXXX.
     
    From the addPhoneReq schema, if you know what to look for you can see that the name/product/model/class/protocol fields are all required (minOccurs="0" does not appear).  Still doesn't help with the 'ItemX' mapping, though:
     
    ...
          <xsd:sequence>
             <xsd:element name="name" type="axlapi:UniqueString128"/>
             <xsd:element name="description" type="axlapi:String128" minOccurs="0"/>
             <xsd:sequence>
                <xsd:choice>
                   <xsd:element name="product" type="xsd:string">
                      <!--This field is of the type axl:XProduct in AXLEnums.xsd-->
                   </xsd:element>
                   <xsd:element name="productInfo" type="axlapi:XProductInfo"/>
                </xsd:choice>
                <xsd:choice>
                   <xsd:element name="model" type="xsd:string">
                      <!--This field is of the type axl:XModel in AXLEnums.xsd-->
                   </xsd:element>
                   <xsd:element name="modelInfo" type="axlapi:XModelInfo"/>
                </xsd:choice>
                <xsd:element name="class" type="xsd:string">
                   <!--This field is of the type axl:XClass in AXLEnums.xsd-->
                </xsd:element>
             </xsd:sequence>
             <xsd:sequence>
                <xsd:element name="protocol" type="xsd:string">
                   <!--This field is of the type axl:XDeviceProtocol in AXLEnums.xsd-->
                </xsd:element>
                <xsd:element name="protocolSide" type="xsd:string">
                   <!--This field is of the type axl:XProtocolSide in AXLEnums.xsd-->
                </xsd:element>
             </xsd:sequence>
             <xsd:choice minOccurs="0">
                <xsd:element name="callingSearchSpace" type="axlapi:XCallingSearchSpace"/>
                <xsd:element name="callingSearchSpaceName" type="axlapi:String50"/>
             </xsd:choice>
    ...