SOAP calls to CUCM and CUPS

Version 1
    This document was generated from CDN thread

    Created by: Doug Kartio on 25-04-2011 02:55:36 PM
    Hopefully someone can help with this problem.
     
    I can make successful SOAP calls to manipulate the CUCM setup.  I can add add/update line and phones.  I can associate phones with users, etc.  Just like I was in the CUCM addminstration program.
     
    My question revolves around the Cisco Unified Presence Server.  Can I use SOAP to make calls into that system and manipulate data?
     
    If I can, where can I find any documentation about it.  The axlsqltoolkit that comes with each different system, is exactly the same, but the plugin doc certainly leads one to believe you can use SOAP with the Persence Server.
     
    Thanks

    Subject: RE: SOAP calls to CUCM and CUPS
    Replied by: Sascha Monteiro on 26-04-2011 04:31:49 AM
    there are some bit and pieces you can access via SOAP, have a look on the Presence API developer pages;
    Presence API's

    Subject: RE: SOAP calls to CUCM and CUPS
    Replied by: Jamie Lewis on 26-04-2011 05:46:54 PM
    Having this same issue.  Could AXL be used to update user information?  For example, setting the users voicemail profile, conferencing profile, etc....      If it can't be done via AXL, how can these fields be updated programmatically?  There seems to be a real lack of information available about these types of changes.

    Subject: RE: SOAP calls to CUCM and CUPS
    Replied by: Doug Kartio on 02-05-2011 04:02:46 PM
    there are some bit and pieces you can access via SOAP, have a look on the Presence API developer pages;
    Presence API's

     
    So followed this API and can not get the CUPS server to acknowledge my log attempt...
     
    Has anyone actual been able to make a SOAP call to a cups server??
     
    Here is what I have been trying to do:
     

     
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.net.Socket;
    import java.security.cert.CertificateException;
    import java.security.cert.X509Certificate;
     
    import javax.net.ssl.SSLContext;
    import javax.net.ssl.SSLSocket;
    import javax.net.ssl.SSLSocketFactory;
    import javax.net.ssl.TrustManager;
    import javax.net.ssl.X509TrustManager;
     
    public class PostXML_CUPS {
     
      public static void main(String[] args) {
     
        PostXML_CUPS axl = new PostXML_CUPS();
     
        try {
     
     
          // build SOAP request
          String xmldata = "<SOAP-ENV:Envelope " + 
                    "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> " +
                    "<SOAP-ENV:Header/> " +
                    "<SOAP-ENV:Body> " +
                    "     <login xmlns=\"urn:cisco:cup:presence:soap\" force=\"true\" > " +
                    "        <username>TPAUser</username> " +
                    "        <password>password</password> " +
                    "     </login> " +
                    "  </SOAP-ENV:Body> " +
                    "</SOAP-ENV:Envelope> ";
     
          //Create socket
              String path = "/EPASSoap/service/v70";  
              String host = "AAA.BBB.CCC.DDD";
              String port = "8443";
     
           // Implement the certificate-related stuffs required for sending request via https
              X509TrustManager xtm = axl.new MyTrustManager();
              TrustManager[] mytm = { xtm };
              SSLContext ctx = SSLContext.getInstance("SSL");
              ctx.init(null, mytm, null);
              SSLSocketFactory sslFact = (SSLSocketFactory) ctx.getSocketFactory();
              Socket sock = (SSLSocket) sslFact.createSocket(host, Integer.parseInt(port));
     
          //Send header
     
          BufferedWriter  wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(),"UTF-8"));
          wr.write("POST " + path + " HTTP/1.1\r\n");
          wr.write("Content-Type: application/soap+xml; charset=UTF-8; action=\"urn:cisco:cup:presence:soap/login\"\r\n");
          wr.write("Connection: Keep-Alive\r\n");
          wr.write("Host: " + host + ":" + port + "\r\n");
          wr.write("Content-Length: " + xmldata.length() + "\r\n");
          wr.write("\r\n");
     
          //Send data
          wr.write(xmldata);
          System.out.println(xmldata);
          wr.flush();
     
          // Response
          BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream()));
          String line;
          while((line = rd.readLine()) != null)
      System.out.println(line);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
     
      //  **************************************************************
      //  inner class
     
      /* testing the SSL interface */
      public class MyTrustManager implements X509TrustManager {
          MyTrustManager() {}
          public void checkClientTrusted(X509Certificate chain[], String authType) throws CertificateException {}
          public void checkServerTrusted(X509Certificate chain[], String authType) throws CertificateException {}
          public X509Certificate[] getAcceptedIssuers() {
              return null;
          }
      }
    }

     
     
    When I run this code, I get this back:
     

       <env:Fault>
         <env:Code><env: value>env:Sender</env: value></env:Code>
         <env:Reason><env:Text xml:lang="en">Invalid request.</env:Text></env:Reason>
       </env:Fault>

     
    Anyone got any ideas, or is willing to share their working code?
     
    Thanks

    Subject: RE: SOAP calls to CUCM and CUPS
    Replied by: Doug Kartio on 04-05-2011 10:30:42 AM
    While I couldn't get the above code to work, I was able to tweak the sample code that Cisco sends with the Axltoolkit to work. But not until I discovered that CUCM and CUPS work on different versions of SOAP.

    In CM, you set the soap version with the call:

    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/", this sets the SOAP version as SOAP 1.1

    CUPS is looking for SOAP version 1.2, to you need to use the schema from this uri:

    xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
     
    I figure the problem is somewhere in the HTTP header, but now that I have working code, I probably won't have time to figure out the header problem.  Maybe someone else will have better luck