Using CUMI to get the info of Mailbox

Version 1
    This document was generated from CDN thread

    Created by: chao guo on 16-10-2013 02:22:48 AM
    Hi Team,
    I met a problem when I using the cumi standard interface to get the message from CUC(8.5.1ES16.11900-16),
    But I get the 400 Error for bad Request.I don't know why this error occurs when I using the cumi standard interface.

    the following is how I using this interface to get the message from the unity:

          String authorization="admin:ccie#13241";
          boolean flag=false;
          byte[] bArray = null; // buffer for reading response from
          Socket socket = null; // socket to cupi server
          OutputStream out = null; // output stream to server
          InputStream in = null; // input stream from server
          String sAXLSOAPRequest = "";
          // HTTPS header and SOAP payload
          String sAXLRequest = null; // will hold only the SOAP payload
          //username=CCMAdministrator and password=cisco_cisco
          // base64 encoding of the username and password
          authorization = new sun.misc.BASE64Encoder().encode(authorization.getBytes());
          sAXLSOAPRequest = "GET /vmrest/mailbox/folders/inbox/messages HTTP/1.0\r\n";
          sAXLSOAPRequest += "Host:localhost:8443\r\n";
          sAXLSOAPRequest += "Authorization: Basic " + authorization + "\r\n";
          sAXLSOAPRequest += "Accept: application/*\r\n";
          sAXLSOAPRequest += "Content-type: application/xml\r\n";
          sAXLSOAPRequest += "Content-length: ";
         
          sAXLRequest="";
          // finish the HTTPS Header
          sAXLSOAPRequest += sAXLRequest.length();
          sAXLSOAPRequest += "\r\n\r\n";
          sAXLSOAPRequest += sAXLRequest;
       
          // Implement the certificate-related stuffs required for sending request via https               
          try {
          X509TrustManager xtm = new MyTrustManager();
          TrustManager[] mytm = { xtm };
          SSLContext ctx;
          ctx = SSLContext.getInstance("SSL");
          ctx.init(null, mytm, null);  
          SSLSocketFactory sslFact = (SSLSocketFactory) ctx.getSocketFactory();
          socket = (SSLSocket) sslFact.createSocket("192.168.0.15", 8443);
          in = socket.getInputStream();
      
          // send the request to the server
          // read the response from the server
          StringBuffer sb = new StringBuffer(2048);
          bArray = new byte[2048];
          int ch = 0;
          int sum = 0;
          out = socket.getOutputStream();
          out.write(sAXLSOAPRequest.getBytes());
          while ((ch = in.read(bArray)) != -1) 
          {
                sum += ch;sb.append(new String(bArray, 0, ch));
          }
          socket.close();
      
          // output the response to the standard output
          //System.out.println(sb.toString());
          logger.info(sb.toString());
          flag=true;
          } catch (Exception e) {
          logger.error(" connect error "+e.getMessage());              
          throw new HttpConnectionException();
       }

    By the way,I try to using the CUPI interface of phone systems to "modify,delete" the phone system,but I also get the error of 405 method not allowed.Does this error info means that we can not using this interface to "modify,delete" the phone systems info ?

    Thanks for help.

    Subject: RE: Using CUMI to get the info of Mailbox
    Replied by: Jeff Lindborg on 17-10-2013 10:56:52 AM
    8.5 is a little early - wouldn't suprise me if several items were not implemented fully back there - for tools using REST (either CUPI, CUPI for users or CUMI) I normally set the minimum version for Connection at 8.6.  The Phone system (port groups, media switch, codecs etc...) are all fully editable, create/delete etc... in 10.0 - many of the system level objects were read only in earlier versions - 10.0 enables full functionality for nearly the entire object model...

    Subject: RE: Using CUMI to get the info of Mailbox
    Replied by: chao guo on 17-10-2013 08:02:53 PM
    Jeff Lindborg:
    8.5 is a little early - wouldn't suprise me if several items were not implemented fully back there - for tools using REST (either CUPI, CUPI for users or CUMI) I normally set the minimum version for Connection at 8.6.  The Phone system (port groups, media switch, codecs etc...) are all fully editable, create/delete etc... in 10.0 - many of the system level objects were read only in earlier versions - 10.0 enables full functionality for nearly the entire object model...

        Hi Jeff,

        Thanks for quick reply,I will try it in CUCM 10 and CUC 10.0.

    Subject: RE: Using CUMI to get the info of Mailbox
    Replied by: chao guo on 24-10-2013 05:14:52 AM
    Jeff Lindborg:
    8.5 is a little early - wouldn't suprise me if several items were not implemented fully back there - for tools using REST (either CUPI, CUPI for users or CUMI) I normally set the minimum version for Connection at 8.6.  The Phone system (port groups, media switch, codecs etc...) are all fully editable, create/delete etc... in 10.0 - many of the system level objects were read only in earlier versions - 10.0 enables full functionality for nearly the entire object model...
        Hi Jeff,

        I using the CUC 10 beta version to test the cupi interface of phonesystems,port groups,and ports, most of them is ok.
        but only one of them can not be successfully added <POST" method of port groups>.
        
        That means port groups can not be successfully added in the CUC 10 beta.
        
        the following is the request info: 
       
        POST  /vmrest/portgroups/8a331e2c-c265-4f8f-b0c7-04898b0f29df  HTTP/1.0\r\n"
        Host:localhost:8443\r\n"
        Authorization: Basic " + authorization + "\r\n"
        Accept: application/*\r\n"
        Content-type: application/xml\r\n"
        Content-length: "
               
        <PortGroup>
        <DisplayName>PortGroup-4</DisplayName>
        <HostOrIPAddress>10.78.171.158</HostOrIPAddress>
        <SkinnyDevicePrefix>PortGroup-4-VI</SkinnyDevicePrefix>
        <SipDoSRTP>true</SipDoSRTP>
        <SipDoAuthenticate>false</SipDoAuthenticate>
        <SipRegisterWithProxyServer>false</SipRegisterWithProxyServer>
        <MwiMinRequestIntervalMs>0</MwiMinRequestIntervalMs>
        </PortGroup>

        The following info is the response info I got:
        
        HTTP/1.1 405 Method Not Allowed
        Set-Cookie: JSESSIONIDSSO=BE1CBBFD36B08E14CADCB8C1D92FA53F; Path=/; Secure; HttpOnly
        Set-Cookie: JSESSIONID=AFBFEF395873446E648DDCD1D5F1550A; Path=/vmrest/; Secure; HttpOnly
        Set-Cookie: REQUEST_TOKEN_KEY=724382791895600937; Path=/; Secure; HttpOnly
        X-Frame-Options: SAMEORIGIN
        Allow: GET,DELETE,OPTIONS,HEAD,PUT
        Content-Type: text/html;charset=utf-8
        Content-Length: 2245
        Date: Thu, 24 Oct 2013 09:21:42 GMT
        Connection: close
        Server:  

        Does this info "Allow: GET,DELETE,OPTIONS,HEAD,PUT" means,this interface do not support "POST" method ?
        Because I using the beta version of CUC 10 ,Is there any license constraint for the interface ?
      
        Thanks a lot.

    Subject: RE: Using CUMI to get the info of Mailbox
    Replied by: Jeff Lindborg on 26-10-2013 10:33:23 AM
    Sure you can create port groups – the other insterfaces allowing for creation and editing would be meaningless if you can’t create a port group or a port.  I just poped up the .NET SDK for CUPI and wrote this code:
    ConnectionServerRest  connectionServer = new ConnectionServerRest ("lindborgload7.cisco.com", "CCMAdministrator", "ecsbulab");
    PortGroup oGroup;
    List<PhoneSystem> oPhones;
     
    PhoneSystem.GetPhoneSystems(connectionServer, out oPhones);
    PortGroup.AddPortGroup(connectionServer, "jeffs port group", oPhones[0].ObjectId, "10.20.30.40", TelephonyIntegrationMethodEnum.SCCP, "prefix-VI",out oGroup);
     
     
    And it created a port group (SCCP) no problem – executed with Fiddler open the port group creation call in HTTP looks like this:
    POST https://lindborgload7.cisco.com:8443/vmrest/portgroups
    Body:
    <PortGroup>
      <DisplayName>jeffs port group</DisplayName>
      <MediaPortGroupTemplateObjectId>90dd306f-b8af-46b6-8289-f13437cc1e5e</MediaPortGroupTemplateObjectId>
      <MediaSwitchObjectId>c133af88-d120-4acc-a53c-01b5864b0318</MediaSwitchObjectId>
      <HostOrIPAddress>10.20.30.40</HostOrIPAddress>
      <TelephonyIntegrationMethodEnum>1</TelephonyIntegrationMethodEnum>
      <SkinnyDevicePrefix>prefix-VI</SkinnyDevicePrefix>
    </PortGroup>
     
    201 response:
    /vmrest/portgroups/185775df-39eb-460b-a094-663e083adf6d
    I’m working with build 298 which is a number of builds old now – I’m quite sure this worked earlier than that since it’s part of my integration tests in the SDK referenced above.

    Subject: RE: Using CUMI to get the info of Mailbox
    Replied by: Jeff Lindborg on 27-10-2013 08:41:43 PM
    no, there's no license issue - you mentioned "Beta version" of 10.0 but have failed to provide version info - although I doubt that matters much here.  Look again at the post you're making, it does not match mine - you're tacking on a GUID to the end of your URI which is wrong - when you create a port group you pass the media switch ObjectId in the body, you do not include it in the URI path - I suspect this is the source of your problem.

    Subject: RE: Using CUMI to get the info of Mailbox
    Replied by: chao guo on 27-10-2013 08:36:36 PM
    Jeff Lindborg:
    Sure you can create port groups – the other insterfaces allowing for creation and editing would be meaningless if you can’t create a port group or a port.  I just poped up the .NET SDK for CUPI and wrote this code:
    ConnectionServerRest  connectionServer = new ConnectionServerRest ("lindborgload7.cisco.com", "CCMAdministrator", "ecsbulab");
    PortGroup oGroup;
    List<PhoneSystem> oPhones;
     
    PhoneSystem.GetPhoneSystems(connectionServer, out oPhones);
    PortGroup.AddPortGroup(connectionServer, "jeffs port group", oPhones[0].ObjectId, "10.20.30.40", TelephonyIntegrationMethodEnum.SCCP, "prefix-VI",out oGroup);
     
     
    And it created a port group (SCCP) no problem – executed with Fiddler open the port group creation call in HTTP looks like this:
    POST https://lindborgload7.cisco.com:8443/vmrest/portgroups
    Body:
    <PortGroup>
      <DisplayName>jeffs port group</DisplayName>
      <MediaPortGroupTemplateObjectId>90dd306f-b8af-46b6-8289-f13437cc1e5e</MediaPortGroupTemplateObjectId>
      <MediaSwitchObjectId>c133af88-d120-4acc-a53c-01b5864b0318</MediaSwitchObjectId>
      <HostOrIPAddress>10.20.30.40</HostOrIPAddress>
      <TelephonyIntegrationMethodEnum>1</TelephonyIntegrationMethodEnum>
      <SkinnyDevicePrefix>prefix-VI</SkinnyDevicePrefix>
    </PortGroup>
     
    201 response:
    /vmrest/portgroups/185775df-39eb-460b-a094-663e083adf6d
    I’m working with build 298 which is a number of builds old now – I’m quite sure this worked earlier than that since it’s part of my integration tests in the SDK referenced above.
        Dear Jeff,

        Thanks for your reply.
        I try to using the same request like you in Java....like the following:
     
        POST  /vmrest/portgroups/8a331e2c-c265-4f8f-b0c7-04898b0f29df  HTTP/1.0\r\n
        Host:localhost:8443\r\n
       "Authorization: Basic " + authorization + "\r\n"
       "Accept: application/*\r\n"
       "Content-type: application/xml\r\n"
       "Content-length: "
       <PortGroup>
       <MediaPortGroupTemplateObjectId>90dd306f-b8af-46b6-8289- f13437cc1e5e</MediaPortGroupTemplateObjectId>
       <MediaSwitchObjectId>8a331e2c-c265-4f8f-b0c7-04898b0f29df</MediaSwitchObjectId>
       <DisplayName>PortGroup-4</DisplayName>
       <HostOrIPAddress>10.78.171.158</HostOrIPAddress>
       <SkinnyDevicePrefix>PortGroup-4-VI</SkinnyDevicePrefix>
       <SipDoSRTP>true</SipDoSRTP>
       <SipDoAuthenticate>false</SipDoAuthenticate>
       <SipRegisterWithProxyServer>false</SipRegisterWithProxyServer>
       <MwiMinRequestIntervalMs>0</MwiMinRequestIntervalMs>
       </PortGroup>

        I also get the server response info of "405 method not allowed".

        I am not sure whether there have any license constraints for the method execute ?  Because I use the beta version of cuc 10 of trial license..

        Many thanks,it's emergency for me ? 

    Subject: RE: Using CUMI to get the info of Mailbox
    Replied by: chao guo on 27-10-2013 08:59:38 PM
    Jeff Lindborg:
    Sure you can create port groups – the other insterfaces allowing for creation and editing would be meaningless if you can’t create a port group or a port.  I just poped up the .NET SDK for CUPI and wrote this code:
    ConnectionServerRest  connectionServer = new ConnectionServerRest ("lindborgload7.cisco.com", "CCMAdministrator", "ecsbulab");
    PortGroup oGroup;
    List<PhoneSystem> oPhones;
     
    PhoneSystem.GetPhoneSystems(connectionServer, out oPhones);
    PortGroup.AddPortGroup(connectionServer, "jeffs port group", oPhones[0].ObjectId, "10.20.30.40", TelephonyIntegrationMethodEnum.SCCP, "prefix-VI",out oGroup);
     
     
    And it created a port group (SCCP) no problem – executed with Fiddler open the port group creation call in HTTP looks like this:
    POST https://lindborgload7.cisco.com:8443/vmrest/portgroups
    Body:
    <PortGroup>
      <DisplayName>jeffs port group</DisplayName>
      <MediaPortGroupTemplateObjectId>90dd306f-b8af-46b6-8289-f13437cc1e5e</MediaPortGroupTemplateObjectId>
      <MediaSwitchObjectId>c133af88-d120-4acc-a53c-01b5864b0318</MediaSwitchObjectId>
      <HostOrIPAddress>10.20.30.40</HostOrIPAddress>
      <TelephonyIntegrationMethodEnum>1</TelephonyIntegrationMethodEnum>
      <SkinnyDevicePrefix>prefix-VI</SkinnyDevicePrefix>
    </PortGroup>
     
    201 response:
    /vmrest/portgroups/185775df-39eb-460b-a094-663e083adf6d
    I’m working with build 298 which is a number of builds old now – I’m quite sure this worked earlier than that since it’s part of my integration tests in the SDK referenced above.
        Thanks Jeff,I resolved.it,becuase my request body not using the corrected order of  the tag info ,like "displayName","MediaPortGroupTemplateObjectId","TelephonyIntegrationMethodEnum" and so on .
        thanks