Associating phone with user

Version 1
    This document was generated from CDN thread

    Created by: Doug Kartio on 19-04-2011 02:54:09 PM
    I have been able to create new phones by sending in the following XML:
     
    <axl:addPhone xmlns:axl="http://www.cisco.com/AXL/API/7.1" sequence="1">
      <newPhone>
        <name>TestPhone</name>
        <description>Test Phone</description>
        <product>Cisco Unified Client Services Framework</product>
        <model>Cisco Unified Client Services Framework</model>
        <class>Phone</class>
        <protocol>SIP</protocol>
        <protocolSide>User</protocolSide>
        <devicePoolName>CA128CLA_DP</devicePoolName>
      </newPhone>
    </axl:addPhone>
     
    This works fine.  The device is added and I can see it in the CM admin application.  The problem is when I try and associate the device with a user.  If I add the ownerUserId tag:
    <ownerUserId>wgretzky</ownerUserId>
     
    or if I run the following XML:
     
    <axl:updateUser xmlns:axl="http://www.cisco.com/AXL/API/7.1" sequence="1">
      <userId>wgretzky</userId>
      <asscoiatedDevices>
        <device>TestPhone</device>
      </asscoiatedDevices>
    </axl:updateUser>
     
    I get a positive responsive, but when I look at the user's associated devices.  Nothing has been added.  When I add the owerUserId tag, the device even shows the owner as wgretzky.
     
    What needs to be done to actually create a new device and assoicate it with a user.
     
    Thanks
     
     
     

    Subject: RE: Associating phone with user
    Replied by: Erick Wellnitz on 19-04-2011 08:34:36 PM
    Your device tag should probably look something like this (SEP plus MAC address):

    <device>SEP000000111111</device>

    Subject: Re: New Message from Doug Kartio in Administration XML (AXL) - Administrati
    Replied by: Sascha Monteiro on 19-04-2011 08:54:37 PM
    you have a typo in the element...quite often the AXL API doesn't error on these occasions...

    use <associatedDevices> instead of <asscoiatedDevices>

    regards
    Sascha

    On 20/04/2011, at 4:54 AM, Cisco Developer Community Forums wrote:

    > Doug Kartio has created a new message in the forum "Administration XML Questions":
    >
    > --------------------------------------------------------------
    > I have been able to create new phones by sending in the following XML:

    > <axl:addPhone xmlns:axl="http://www.cisco.com/AXL/API/7.1" sequence="1">
    >   <newPhone>
    >     <name>TestPhone</name>
    >     <description>Test Phone</description>
    >     <product>Cisco Unified Client Services Framework</product>
    >     <model>Cisco Unified Client Services Framework</model>
    >     <class>Phone</class>
    >     <protocol>SIP</protocol>
    >     <protocolSide>User</protocolSide>
    >     <devicePoolName>CA128CLA_DP</devicePoolName>
    >   </newPhone>
    > </axl:addPhone>

    > This works fine.  The device is added and I can see it in the CM admin application.  The problem is when I try and associate the device with a user.  If I add the ownerUserId tag:
    > <ownerUserId>wgretzky</ownerUserId>

    > or if I run the following XML:

    > <axl:updateUser xmlns:axl="http://www.cisco.com/AXL/API/7.1" sequence="1">
    >   <userId>wgretzky</userId>
    >   <asscoiatedDevices>
    >     <device>TestPhone</device>
    >   </asscoiatedDevices>
    > </axl:updateUser>

    > I get a positive responsive, but when I look at the user's associated devices.  Nothing has been added.  When I add the owerUserId tag, the device even shows the owner as wgretzky.

    > What needs to be done to actually create a new device and assoicate it with a user.

    > Thanks



    > --
    > To respond to this post, please click the following link:
    >
    > <http://developer.cisco.com/web/axl/forums/-/message_boards/view_message/3749530>
    >
    > or simply reply to this email.

    Subject: RE: Associating phone with user
    Replied by: Doug Kartio on 20-04-2011 01:45:31 PM
    OK, so removing my spelling mistake for the XML.

    I get an ERROR back from the SOAP server

    ERROR: Cannot insert a null into column (enduserdevicemap.fkenduser).

    I am providing the userId, so what is it else is it expecting??

    I should state that I am running on CM version 7.1.3

    Subject: RE: Associating phone with user
    Replied by: Doug Kartio on 20-04-2011 02:21:49 PM
    The fkenduser field in the enduserdevicemap table is looking for the pkid of the user we are working with.  The 7.1.2 XML schema does have an reference to it.  The 8.0 schema requires the UUID for the user.

    I included the uuid within the XML

    <uuid>85e80056-4016-48de-96d1-0c02db384c4b</uuid>

    to see if that took care of the NULL issue.  But the

    ERROR: Cannot insert a null into column (enduserdevicemap.fkenduser).

    continues to exist.   Any ideas????
     
    I have also tried variations of the UUID as
     
    <uuid>\{85e80056-4016-48de-96d1-0c02db384c4b\}</uuid>
    <uuid>{85e80056-4016-48de-96d1-0c02db384c4b}</uuid>
     
    Here is teh complete SOAP call:
     
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header/><SOAP-ENV:Body><axl:updateUser xmlns:axl="http://www.cisco.com/AXL/API/8.5" sequence="1" xsi:schemaLocation="http://www.cisco.com/AXL/API/8.5 http://ccmserver/schema/axlsoap.xsd" xsi:type="XRequest"><userId>wgretzky</userId><uuid>{85e80056-4016-48de-96d1-0c02db384c4b}</uuid><associatedDevices><device>TestPhone</device></associatedDevices></axl:updateUser></SOAP-ENV:Body></SOAP-ENV:Envelope>
     
    I have also run this with the APi set to 7.1, instead of 8.5

    Subject: RE: Associating phone with user
    Replied by: WILL DELAUGHTER on 20-04-2011 03:28:39 PM
    Not sure why it's not working for you.  This is how mine is crafted and it seems to work just fine for version 7.1(5):

    <axl:updateUser xmlns:axl="http://www.cisco.com/AXL/API/1.0" sequence="1">
         <user>
              <userid>bob</userid>
              <associatedDevices>
                   <device>SEP111122223333</device>
              </associatedDevices>
         </user>
    </axl:updateUser>

    Subject: RE: Associating phone with user
    Replied by: Doug Kartio on 20-04-2011 06:06:30 PM
    Will -

    That helped.  Turns out that the problem was that I had "userId", instead of "userid".  Also I wasn't wrapping everything in the <user> tag.

    I did find that you don't need the wrapping <user> tag to get things to work.

    So, I am to take it that SOAP engine is not validating the incoming XML against the TLD/XSD???  I should have had an "invalid XML" error returned by both of the spelling errors, and yet it tried to process the XML, even though it was misformed.
     
     
    BTW..  Thanks Will, much appreciated!!!!

    Subject: RE: Associating phone with user
    Replied by: WILL DELAUGHTER on 21-04-2011 09:42:27 AM
    Doug -

    Maybe a Cisco dev trolling the forums can answer that question in more depth, but I can confirm that it's very quirky what the reponses are when it comes to error validation.  My application has a debug area with 2 windows and I can basically paste any arbitrary command into one and hit send and get the response so when I find something erroring I play with the syntax until I get it right (often having to refer back to AXL documentation for that specific version or performing a getXXXX to see how it's crafted in the response).  Most of the time you get "error...expecting xxxx and found yyyy," but often you get a generic error that means absolutely nothing when it comes to debugging your syntax.  Yes, capitalization is critical. 

    The <user> tag I think is only required for older CUCM versions (4.x).  If I remember correctly, I put that in there either because it exists in the getUser response or because 4.x choked without it, but 7.x accepts it and I didn't feel like splitting the different versions out in my class functions at the time.

    Glad I could help!