├── .classpath ├── .env.example ├── .gitignore ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── .vscode └── launch.json ├── LICENSE ├── README.md ├── certificate └── .gitignore ├── images ├── cert_list.png └── launch.png ├── pom.xml ├── schema ├── AXLAPI.wsdl ├── AXLEnums.xsd └── AXLSoap.xsd └── src └── main └── java └── com └── cisco └── axlsamples ├── addAppUser.java ├── addCtiRoutePoint.java ├── addMobilityProfile.java ├── addPhone.java ├── executeSqlQuery.java ├── getEnterprisePhoneConfig.java └── getPhone.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # Configuration 2 | 3 | CUCM= 4 | AXL_USER= 5 | AXL_PASSWORD= 6 | 7 | DEBUG=False -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Standard Maven .gitignore 3 | # 4 | target/ 5 | pom.xml.tag 6 | pom.xml.releaseBackup 7 | pom.xml.versionsBackup 8 | pom.xml.next 9 | release.properties 10 | dependency-reduced-pom.xml 11 | buildNumber.properties 12 | .mvn/timing.properties 13 | 14 | # 15 | # IntelliJ 16 | # 17 | *.iml 18 | .idea/* 19 | !.idea/runConfigurations/ 20 | 21 | # 22 | # Visual Studio Code 23 | # 24 | /.settings/ 25 | /.classpath 26 | /.project 27 | /.factorypath 28 | 29 | # DevNet additions 30 | 31 | .DS_Store 32 | certificate/* 33 | src/main/java/com/cisco/axlsamples/api/** 34 | .vscode/settings.json 35 | .env 36 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | axl-java-samples 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | 25 | 1611591230861 26 | 27 | 30 28 | 29 | org.eclipse.core.resources.regexFilterMatcher 30 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 3 | org.eclipse.jdt.core.compiler.compliance=11 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 8 | org.eclipse.jdt.core.compiler.release=disabled 9 | org.eclipse.jdt.core.compiler.source=11 10 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "java", 9 | "name": "Launch addMobilityProfile", 10 | "request": "launch", 11 | "mainClass": "com.cisco.axlsamples.addMobilityProfile", 12 | "projectName": "axl-java-samples" 13 | }, 14 | { 15 | "type": "java", 16 | "name": "Launch getPhone", 17 | "request": "launch", 18 | "mainClass": "com.cisco.axlsamples.getPhone", 19 | "projectName": "axl-java-samples" 20 | }, 21 | { 22 | "type": "java", 23 | "name": "Launch executeSqlQuery", 24 | "request": "launch", 25 | "mainClass": "com.cisco.axlsamples.executeSqlQuery", 26 | "projectName": "axl-java-samples" 27 | }, 28 | { 29 | "type": "java", 30 | "name": "Launch getEnterprisePhoneConfig", 31 | "request": "launch", 32 | "mainClass": "com.cisco.axlsamples.getEnterprisePhoneConfig", 33 | "projectName": "axl-java-samples" 34 | }, 35 | { 36 | "type": "java", 37 | "name": "Launch addCtiRoutePoint", 38 | "request": "launch", 39 | "mainClass": "com.cisco.axlsamples.addCtiRoutePoint", 40 | "projectName": "axl-java-samples" 41 | }, 42 | { 43 | "type": "java", 44 | "name": "Launch addPhone", 45 | "request": "launch", 46 | "mainClass": "com.cisco.axlsamples.addPhone", 47 | "projectName": "axl-java-samples" 48 | }, 49 | { 50 | "type": "java", 51 | "name": "Launch addAppUser", 52 | "request": "launch", 53 | "mainClass": "com.cisco.axlsamples.addAppUser", 54 | "projectName": "axl-java-samples" 55 | } 56 | ] 57 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Cisco Systems, Inc. and/or its affiliates 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # axl-java-samples 2 | 3 | ## Overview 4 | 5 | Sample Visual Studio Code project demonstrating usage of the Cisco CUCM AXL SOAP API using OpenJDK 11 and the Eclipse EEE4J JAX-WS packages. 6 | 7 | Visit the [AXL Developer Site](https://developer.cisco.com/site/axl/) 8 | 9 | This project was tested using: 10 | 11 | * Ubuntu 20.10 / Mac 10.15.6 12 | * OpenJDK 11 13 | * Eclipse EEE4J Metro JAX-WS 14 | 15 | >Note: the `java8` branch is available for supporting Oracle Java 8, however the Redhat Java plugin for VS Code no longer supports Java 8, so the project may not run with VS Code 16 | 17 | ## Available samples 18 | 19 | * `getPhone.java` - Demonstrates querying for configuration information for a specific phone by device name (``) 20 | 21 | * `addMobilityProfile.java` - Add a new Mobility Profile (``, ``) 22 | 23 | * `executeSqlQuery.java` - Performs an executeSqlQuery operation for the applicationusers table and extracts the name and pkid from the response (``) 24 | 25 | * `getEnterprisePhoneConfig.java` - Performs a ``, then parses/prints a simple report to the console. 26 | 27 | * `addCtiRoutePoint.java` - Performs ``, then creates a new CTI Route Point using the line with ``. 28 | 29 | * `addPhone.java` - Performs ``, then creates a new CTI Port using the line with ``. 30 | 31 | * `addAppUser.java` - Performs `` and `` with the new line, then creates an Application User with the new device assigned. 32 | 33 | ## Getting started 34 | 35 | 1. Make sure you have OpenJDK 11 installed, `java` is available in the path, and the JAVA_HOME environment variable is set: 36 | 37 | ```shell 38 | $ java -version 39 | # Example output 40 | openjdk version "11.0.8" 2020-07-14 41 | OpenJDK Runtime} Environment AdoptOpenJDK (build 11.0.8+10) 42 | OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode) 43 | ``` 44 | 45 | ```shell 46 | $ echo $JAVA_HOME 47 | # Example output 48 | /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home 49 | ``` 50 | 51 | 1. Open a terminal and use `git` to clone this repository: 52 | 53 | ```bash 54 | git clone https://github.com/CiscoDevNet/axl-java-samples.git 55 | ``` 56 | 57 | 1. If you need to use Oracle JDK8, checkout branch `java8` (future additional samples may appear only in branch `master`, currently supporting OpenJDK 11): 58 | 59 | ```bash 60 | cd axl-java-samples 61 | git checkout java8 62 | ``` 63 | 64 | 1. Download the CUCM Tomcat HTTPS certificate and place in the `certificate/` folder: 65 | 66 | 1. Browse to the CUCM OS admin web pages: `https://{cucm}/cmplatform/showHome.do` 67 | 68 | 1. Navigate to **Security** / **Certificate Management** 69 | 70 | 1. Click **Find** and select the **tomcat** item: 71 | 72 | ![cert_list](images/cert_list.png) 73 | 74 | 1. Click **Download .PEM File**, and save into this project's `certificate/` folder. You may want to give it a recognizable name e.g. the CUCM host name. 75 | 76 | 1. Import the CUCM Tomcat HTTPS certificate into a local Java keystore. 77 | 78 | >Note: you may want to first copy the default Java `cacerts` file from `$JAVA_HOME/lib/security/cacerts` to `certificates/cacerts` to retain the default certs that ship with Java. Be sure to set file ownership appropriately. 79 | 80 | The following command works on Ubuntu/Mac, see the Oracle Java documentation for more info on managing Java certificates. Be sure to replace `{CUCM_NAME}` and `{CERT_FILE_NAME}` with your particular values: 81 | 82 | ```bash 83 | $JAVA_HOME/bin/keytool -trustcacerts -keystore certificate/cacerts -alias {CUCM_NAME} -import -file certificate/{CERT_FILE_NAME} 84 | ``` 85 | 86 | >Note: the default password for the default `cacerts` keystore is: `changeit` 87 | 88 | 1. The CUCM 12.5 version of the AXL WSDL files are included in this proect. If want to use a different AXL version, download the AXL WSDL files for your CUCM version: 89 | 90 | 1. From the CUCM Administration UI, download the 'Cisco AXL Tookit' from **Applications** / **Plugins** 91 | 92 | 1. Unzip the Toolkit, and navigate to the `schema/current` folder 93 | 94 | 1. Copy/replace the three WSDL files into this project's `schema/` folder: 95 | 96 | ```bash 97 | AXLAPI.wsdl 98 | AXLEnums.xsd 99 | AXLSoap.xsd 100 | ``` 101 | 102 | 1. Open the `axl-java-samples` Java project in [Visual Studio Code](https://code.visualstudio.com/): 103 | 104 | ```bash 105 | code . 106 | ``` 107 | 108 | 1. If you haven't developed Java with VS Code before, you may need to install the 'Java Extention Pack' (vscjava.vscode) extension. 109 | 110 | Upon first opening the project in VS Code, click 'Yes' import the project into the workspace, then allow some time for VS Code and Maven to auto-generate the AXL API source/code from the AXL WSDL. 111 | 112 | 1. Once the AXL API source files have been automatically generated (found under `src/main/java/com/cisco/apxsamples/api/`), and compiled (found under `target/classes/com/cisco/axlsamples/api/`): 113 | 114 | * From the file **Explorer** tab, highlight `pom.xml`. 115 | 116 | * Open the VS Code command window and run the **Java: Update project configuration** command. 117 | 118 | 1. Rename the `.env.example` file to `.env`, and edit it to specify your CUCM hostname and AXL API user credentials. 119 | 120 | >Note: you can specify the config values as environment variables using your preferred method, if desired 121 | 122 | 1. Finally, to launch one of the available samples, in VS Code select the **Debug** panel, choose a launch configuration from the dropdown-list in the upper-left, and click the green **Start Debugging** arrow: 123 | 124 | ![Launch](images/launch.png) 125 | 126 | ## Hints 127 | 128 | * Samples include AXL XML request/response debugging functionaly. To enable set `DEBUG=True` in `.env` 129 | 130 | * The AXL schema is huge, and will consume a lot of memory during compilation and execution, including for things like Intellisense. You may see better performance in VS Code by increasing the max memory allowed for the VS Code Java engine via the `settings.json` file, e.g. to allocate 8GB of max memory: 131 | 132 | ```json 133 | "java.jdt.ls.vmargs": "-Xmx8G -Xms100m" 134 | ``` -------------------------------------------------------------------------------- /certificate/.gitignore: -------------------------------------------------------------------------------- 1 | ** 2 | !.gitignore -------------------------------------------------------------------------------- /images/cert_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoDevNet/axl-java-samples/bb061c0cbdfb87eaf0c6db6e34b83f4758bfe281/images/cert_list.png -------------------------------------------------------------------------------- /images/launch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CiscoDevNet/axl-java-samples/bb061c0cbdfb87eaf0c6db6e34b83f4758bfe281/images/launch.png -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | com.cisco.axlsamples 4 | axl-java-samples 5 | 2.0 6 | 7 | 11 8 | 11 9 | UTF-8 10 | 11 | 12 | 13 | io.github.cdimascio 14 | java-dotenv 15 | 5.1.3 16 | 17 | 18 | javax.jws 19 | javax.jws-api 20 | 1.1 21 | 22 | 23 | com.sun.xml.ws 24 | jaxws-tools 25 | 2.3.3 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | maven-clean-plugin 34 | 3.1.0 35 | 36 | 37 | 38 | maven-resources-plugin 39 | 3.0.2 40 | 41 | 42 | maven-compiler-plugin 43 | 3.8.0 44 | 45 | 46 | maven-surefire-plugin 47 | 2.22.1 48 | 49 | 50 | maven-jar-plugin 51 | 3.0.2 52 | 53 | 54 | maven-install-plugin 55 | 2.5.2 56 | 57 | 58 | maven-deploy-plugin 59 | 2.8.2 60 | 61 | 62 | 63 | maven-site-plugin 64 | 3.7.1 65 | 66 | 67 | maven-project-info-reports-plugin 68 | 3.0.0 69 | 70 | 71 | org.codehaus.mojo 72 | jaxws-maven-plugin 73 | 2.6 74 | 75 | 76 | 77 | 78 | 79 | org.codehaus.mojo 80 | jaxws-maven-plugin 81 | 82 | 83 | basic 84 | generate-sources 85 | 86 | wsimport 87 | 88 | 89 | com.cisco.axlsamples.api 90 | ${basedir}/schema 91 | 92 | AXLAPI.wsdl 93 | 94 | ${basedir}/schema 95 | 96 | AXLSoap.xsd 97 | 98 | ${basedir}/src/main/java 99 | ${basedir}/target/classes 100 | false 101 | 102 | -Djavax.xml.accessExternalSchema=all 103 | 104 | true 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /src/main/java/com/cisco/axlsamples/addAppUser.java: -------------------------------------------------------------------------------- 1 | package com.cisco.axlsamples; 2 | 3 | // Performs and with the new line, then creates an Application 4 | // user with the new device assigned. 5 | // Finally, , and AXL API operations 6 | // are used to clean up. 7 | 8 | // Copyright (c) 2021 Cisco and/or its affiliates. 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | 25 | import java.util.Map; 26 | import java.util.List; 27 | 28 | import javax.xml.bind.JAXBElement; 29 | import javax.xml.ws.BindingProvider; 30 | 31 | import java.security.cert.X509Certificate; 32 | import java.security.KeyManagementException; 33 | import java.security.NoSuchAlgorithmException; 34 | import java.security.cert.CertificateException; 35 | import javax.net.ssl.SSLContext; 36 | import javax.net.ssl.X509TrustManager; 37 | 38 | // import only the XL package modules needed for this sample 39 | import com.cisco.axlsamples.api.AXLAPIService; 40 | import com.cisco.axlsamples.api.AXLPort; 41 | import com.cisco.axlsamples.api.AddPhoneReq; 42 | import com.cisco.axlsamples.api.AddLineReq; 43 | import com.cisco.axlsamples.api.AddAppUserReq; 44 | import com.cisco.axlsamples.api.NameAndGUIDRequest; 45 | import com.cisco.axlsamples.api.ObjectFactory; 46 | import com.cisco.axlsamples.api.RemoveAppUserReq; 47 | import com.cisco.axlsamples.api.RemoveLineReq; 48 | import com.cisco.axlsamples.api.StandardResponse; 49 | import com.cisco.axlsamples.api.XPhone.Lines; 50 | import com.cisco.axlsamples.api.XLine; 51 | import com.cisco.axlsamples.api.XNumplanIdentifier; 52 | import com.cisco.axlsamples.api.XFkType; 53 | import com.cisco.axlsamples.api.XPhone; 54 | import com.cisco.axlsamples.api.XAppUser; 55 | import io.github.cdimascio.dotenv.Dotenv; 56 | 57 | // To import the entire AXL package contents: 58 | // 59 | // import com.cisco.axl.api.*; 60 | 61 | public class addAppUser { 62 | 63 | public static void main(String[] args) { 64 | 65 | // Retrieve environment variables from .env, if present 66 | Dotenv dotenv = Dotenv.load(); 67 | 68 | Boolean debug = dotenv.get( "DEBUG" ).equals( "True" ); 69 | 70 | if ( debug ) { 71 | System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true"); 72 | // Increase the dump output permitted size 73 | System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dumpTreshold", "999999"); 74 | } 75 | 76 | // Verify the JVM has a console for user input 77 | if ( System.console() == null ) { 78 | System.err.println( "Error: This sample app requires a console" ); 79 | System.exit( 1 ); 80 | } 81 | 82 | // Instantiate the generated AXL API Service client 83 | AXLAPIService axlService = new AXLAPIService(); 84 | 85 | // Get access to the request context so we can set custom params 86 | AXLPort axlPort = axlService.getAXLPort(); 87 | Map< String, Object > requestContext = ( ( BindingProvider ) axlPort ).getRequestContext(); 88 | 89 | // Set the AXL API endpoint address, user, and password 90 | // for our particular environment in the JAX-WS client. 91 | // Configure these values in .env 92 | requestContext.put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://" + dotenv.get( "CUCM" ) + ":8443/axl/"); 93 | requestContext.put( BindingProvider.USERNAME_PROPERTY, dotenv.get( "AXL_USER" ) ); 94 | requestContext.put( BindingProvider.PASSWORD_PROPERTY, dotenv.get( "AXL_PASSWORD" ) ); 95 | // Enable cookies for AXL authentication session reuse 96 | requestContext.put( BindingProvider.SESSION_MAINTAIN_PROPERTY, true ); 97 | 98 | // Uncomment the section below to disable HTTPS certificate checking, 99 | // otherwise import the CUCM Tomcat certificate - see README.md 100 | 101 | // X509TrustManager[] trustAll = new X509TrustManager[] { new X509TrustManager() { 102 | // public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } 103 | // public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 104 | // public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 105 | // } 106 | // }; 107 | // SSLContext context = SSLContext.getInstance( "TLS" ); 108 | // context.init( null, trustAll, new java.security.SecureRandom() ); 109 | // provider.getRequestContext().put( "com.sun.xml.ws.transport.https.client.SSLSocketFactory", context.getSocketFactory() ); 110 | 111 | // Use a local trust store file to validate HTTPS certificates. 112 | // Requires importing the CUCM Tomcat certificate from CUCM into file certificate/local_truststore, see README.md 113 | System.setProperty( "javax.net.ssl.trustStore", "certificate/cacerts" ); 114 | System.setProperty( "javax.net.ssl.trustStorePassword", "changeit" ); 115 | 116 | // Create an objectFactory for creating AXL specific objects 117 | ObjectFactory objectFactory = new ObjectFactory(); 118 | 119 | // Create a new line, which will be added along with the CSF device 120 | 121 | AddLineReq addlineReq = new AddLineReq(); 122 | XLine newLine = new XLine(); 123 | newLine.setPattern( "9999" ); 124 | XFkType routePartitionForeignKey = new XFkType(); 125 | routePartitionForeignKey.setValue( null ); 126 | JAXBElement routePartitionName = objectFactory.createXCtiRoutePointDevicePoolName( routePartitionForeignKey ); 127 | newLine.setRoutePartitionName( routePartitionName ); 128 | 129 | addlineReq.setLine( newLine ); 130 | 131 | // Execute the request, wrapped in try/catch in case an exception is thrown 132 | try { 133 | 134 | StandardResponse response = axlPort.addLine( addlineReq ); 135 | 136 | // Dive into the response object's hierarchy to retrieve the value 137 | System.console().format( "%nAdded Line pkid: " + response.getReturn() + "%n%n" ); 138 | 139 | } catch (Exception err) { 140 | 141 | // If an exception occurs, dump the stacktrace to the console 142 | err.printStackTrace(); 143 | } 144 | 145 | System.console().readLine( "Press Enter to continue..." ); 146 | 147 | // Create a new request object and its sub-objects 148 | // Indentation here attempts to represent the object/sub-object hierarchy 149 | // The AXL schema documentation can help in understanding parent/child 150 | // object relations/types 151 | AddPhoneReq addPhoneReq = new AddPhoneReq(); 152 | XPhone phone = new XPhone(); 153 | phone.setName( "testCsfPhone" ); 154 | phone.setProduct( "Cisco Unified Client Services Framework" ); 155 | phone.setClazz( "Phone" ); 156 | phone.setProtocol( "SIP" ); 157 | phone.setProtocolSide( "User" ); 158 | XFkType devicePoolForeignKey = new XFkType(); 159 | devicePoolForeignKey.setValue( "Default" ); 160 | JAXBElement devicePoolName = objectFactory.createXCtiRoutePointDevicePoolName( devicePoolForeignKey ); 161 | phone.setDevicePoolName( devicePoolName ); 162 | XFkType locationForeignKey = new XFkType(); 163 | locationForeignKey.setValue( "Hub_None" ); 164 | phone.setLocationName( locationForeignKey ); 165 | Lines lines = new Lines(); 166 | // This provides a List object pointing to the array 167 | List linesList = lines.getLineIdentifier(); 168 | XNumplanIdentifier line = new XNumplanIdentifier(); 169 | line.setDirectoryNumber( "9999" ); 170 | line.setRoutePartitionName( null ); 171 | // We can use listLines to manipulate the Lines object, i.e. to add a lineIdentifier 172 | linesList.add( line ); 173 | phone.setLines( lines ); 174 | addPhoneReq.setPhone( phone ); 175 | 176 | // Execute the request, wrapped in try/catch in case an exception is thrown 177 | try { 178 | 179 | StandardResponse response = axlPort.addPhone( addPhoneReq ); 180 | 181 | // Dive into the response object's hierarchy to retrieve the value 182 | System.console().format("%nAdded Phone pkid: " + response.getReturn() + "%n%n"); 183 | 184 | } catch (Exception err) { 185 | 186 | // If an exception occurs, dump the stacktrace to the console 187 | err.printStackTrace(); 188 | } 189 | 190 | System.console().readLine("Press Enter to continue..."); 191 | 192 | // Create a new request object and its sub-objects 193 | // Indentation here attempts to represent the object/sub-object hierarchy 194 | // The AXL schema documentation can help in understanding parent/child 195 | // object relations/types 196 | AddAppUserReq addAppUserReq = new AddAppUserReq(); 197 | XAppUser appUser = new XAppUser(); 198 | appUser.setUserid( "testAppUser" ); 199 | appUser.setPassword( "Cisco!123" ); 200 | XAppUser.AssociatedDevices associatedDevices = new XAppUser.AssociatedDevices(); 201 | associatedDevices.getDevice().add( "testCsfPhone" ); 202 | appUser.setAssociatedDevices( associatedDevices ); 203 | XAppUser.AssociatedGroups.UserGroup userGroup = new XAppUser.AssociatedGroups.UserGroup(); 204 | userGroup.setName( "Standard CTI Enabled" ); 205 | XAppUser.AssociatedGroups associatedGroups = new XAppUser.AssociatedGroups(); 206 | associatedGroups.getUserGroup().add( userGroup ); 207 | appUser.setAssociatedGroups( associatedGroups ); 208 | addAppUserReq.setAppUser( appUser ); 209 | 210 | // Execute the request, wrapped in try/catch in case an exception is thrown 211 | try { 212 | 213 | StandardResponse response = axlPort.addAppUser( addAppUserReq ); 214 | 215 | // Dive into the response object's hierarchy to retrieve the value 216 | System.console().format("%nAdded App User pkid: " + response.getReturn() + "%n%n"); 217 | 218 | } catch (Exception err) { 219 | 220 | // If an exception occurs, dump the stacktrace to the console 221 | err.printStackTrace(); 222 | } 223 | 224 | System.console().readLine("Press Enter to continue..."); 225 | 226 | // Remove the newly created objects 227 | 228 | // NameAndGUIDRequest type is commonly used for requests 229 | NameAndGUIDRequest removePhoneReq = new NameAndGUIDRequest(); 230 | 231 | removePhoneReq.setName( "testCsfPhone" ); 232 | 233 | try { 234 | 235 | StandardResponse response = axlPort.removePhone( removePhoneReq ); 236 | 237 | System.console().format( "%nRemoved Phone pkid: " + response.getReturn() + "%n" ); 238 | 239 | } catch ( Exception err ) { 240 | 241 | err.printStackTrace(); 242 | } 243 | 244 | 245 | RemoveLineReq removeLineReq = new RemoveLineReq(); 246 | 247 | removeLineReq.setPattern( "9999" ); 248 | removeLineReq.setRoutePartitionName( routePartitionName ); 249 | 250 | try { 251 | 252 | StandardResponse response = axlPort.removeLine( removeLineReq ); 253 | 254 | System.console().format( "%nRemoved Line pkid: " + response.getReturn() + "%n%n" ) ; 255 | 256 | } catch ( Exception err ) { 257 | 258 | err.printStackTrace(); 259 | } 260 | 261 | RemoveAppUserReq removeAppUserReq = new RemoveAppUserReq(); 262 | 263 | removeAppUserReq.setUserid( "testAppUser" ); 264 | 265 | try { 266 | 267 | StandardResponse response = axlPort.removeAppUser( removeAppUserReq ); 268 | 269 | System.console().format( "%nRemoved App User pkid: " + response.getReturn() + "%n%n" ) ; 270 | 271 | } catch ( Exception err ) { 272 | 273 | err.printStackTrace(); 274 | } 275 | } 276 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/axlsamples/addCtiRoutePoint.java: -------------------------------------------------------------------------------- 1 | package com.cisco.axlsamples; 2 | 3 | // Performs , then creates a new CTI Route Point using the line with 4 | // . Finally, and AXL API operations 5 | // are used to clean up. 6 | 7 | // Copyright (c) 2021 Cisco and/or its affiliates. 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | import java.util.Map; 25 | import java.util.List; 26 | 27 | import javax.xml.bind.JAXBElement; 28 | import javax.xml.ws.BindingProvider; 29 | 30 | import java.security.cert.X509Certificate; 31 | import java.security.KeyManagementException; 32 | import java.security.NoSuchAlgorithmException; 33 | import java.security.cert.CertificateException; 34 | import javax.net.ssl.SSLContext; 35 | import javax.net.ssl.X509TrustManager; 36 | 37 | // import only the XL package modules needed for this sample 38 | import com.cisco.axlsamples.api.AXLAPIService; 39 | import com.cisco.axlsamples.api.AXLPort; 40 | import com.cisco.axlsamples.api.AddCtiRoutePointReq; 41 | import com.cisco.axlsamples.api.AddLineReq; 42 | import com.cisco.axlsamples.api.NameAndGUIDRequest; 43 | import com.cisco.axlsamples.api.ObjectFactory; 44 | import com.cisco.axlsamples.api.RemoveLineReq; 45 | import com.cisco.axlsamples.api.StandardResponse; 46 | import com.cisco.axlsamples.api.XCtiRoutePoint.Lines; 47 | import com.cisco.axlsamples.api.XLine; 48 | import com.cisco.axlsamples.api.XNumplanIdentifier; 49 | import com.cisco.axlsamples.api.XFkType; 50 | import com.cisco.axlsamples.api.XCtiRoutePoint; 51 | import io.github.cdimascio.dotenv.Dotenv; 52 | 53 | // To import the entire AXL package contents: 54 | // 55 | // import com.cisco.axl.api.*; 56 | 57 | public class addCtiRoutePoint { 58 | 59 | public static void main(String[] args) { 60 | 61 | // Retrieve environment variables from .env, if present 62 | Dotenv dotenv = Dotenv.load(); 63 | 64 | Boolean debug = dotenv.get( "DEBUG" ).equals( "True" ); 65 | 66 | if ( debug ) { 67 | System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true"); 68 | // Increase the dump output permitted size 69 | System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dumpTreshold", "999999"); 70 | } 71 | 72 | // Verify the JVM has a console for user input 73 | if ( System.console() == null ) { 74 | System.err.println( "Error: This sample app requires a console" ); 75 | System.exit( 1 ); 76 | } 77 | 78 | // Instantiate the generated AXL API Service client 79 | AXLAPIService axlService = new AXLAPIService(); 80 | 81 | // Get access to the request context so we can set custom params 82 | AXLPort axlPort = axlService.getAXLPort(); 83 | Map< String, Object > requestContext = ( ( BindingProvider ) axlPort ).getRequestContext(); 84 | 85 | // Set the AXL API endpoint address, user, and password 86 | // for our particular environment in the JAX-WS client. 87 | // Configure these values in .env 88 | requestContext.put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://" + dotenv.get( "CUCM" ) + ":8443/axl/"); 89 | requestContext.put( BindingProvider.USERNAME_PROPERTY, dotenv.get( "AXL_USER" ) ); 90 | requestContext.put( BindingProvider.PASSWORD_PROPERTY, dotenv.get( "AXL_PASSWORD" ) ); 91 | // Enable cookies for AXL authentication session reuse 92 | requestContext.put( BindingProvider.SESSION_MAINTAIN_PROPERTY, true ); 93 | 94 | // Uncomment the section below to disable HTTPS certificate checking, 95 | // otherwise import the CUCM Tomcat certificate - see README.md 96 | 97 | // X509TrustManager[] trustAll = new X509TrustManager[] { new X509TrustManager() { 98 | // public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } 99 | // public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 100 | // public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 101 | // } 102 | // }; 103 | // SSLContext context = SSLContext.getInstance( "TLS" ); 104 | // context.init( null, trustAll, new java.security.SecureRandom() ); 105 | // provider.getRequestContext().put( "com.sun.xml.ws.transport.https.client.SSLSocketFactory", context.getSocketFactory() ); 106 | 107 | // Use a local trust store file to validate HTTPS certificates. 108 | // Requires importing the CUCM Tomcat certificate from CUCM into file certificate/local_truststore, see README.md 109 | System.setProperty( "javax.net.ssl.trustStore", "certificate/cacerts" ); 110 | System.setProperty( "javax.net.ssl.trustStorePassword", "changeit" ); 111 | 112 | // Create an objectFactory for creating AXL specific objects 113 | ObjectFactory objectFactory = new ObjectFactory(); 114 | 115 | // Create a new line, which will be added along with the CTI RP 116 | 117 | AddLineReq addlineReq = new AddLineReq(); 118 | XLine newLine = new XLine(); 119 | newLine.setPattern( "9999" ); 120 | XFkType routePartitionForeignKey = new XFkType(); 121 | routePartitionForeignKey.setValue( null ); 122 | JAXBElement routePartitionName = objectFactory.createXCtiRoutePointDevicePoolName( routePartitionForeignKey ); 123 | newLine.setRoutePartitionName( routePartitionName ); 124 | 125 | addlineReq.setLine( newLine ); 126 | 127 | // Execute the request, wrapped in try/catch in case an exception is thrown 128 | try { 129 | 130 | StandardResponse response = axlPort.addLine( addlineReq ); 131 | 132 | // Dive into the response object's hierarchy to retrieve the value 133 | System.console().format( "%nAdded Line pkid: " + response.getReturn() + "%n%n" ); 134 | 135 | } catch (Exception err) { 136 | 137 | // If an exception occurs, dump the stacktrace to the console 138 | err.printStackTrace(); 139 | } 140 | 141 | System.console().readLine( "Press Enter to continue..." ); 142 | 143 | // Create a new request object and its sub-objects 144 | // Indentation here attempts to represent the object/sub-object hierarchy 145 | // The AXL schema documentation can help in understanding parent/child 146 | // object relations/types 147 | AddCtiRoutePointReq addCtiRpReq = new AddCtiRoutePointReq(); 148 | XCtiRoutePoint ctiRp = new XCtiRoutePoint(); 149 | ctiRp.setName( "testRoutePoint" ); 150 | ctiRp.setProduct( "CTI Route Point" ); 151 | ctiRp.setClazz( "CTI Route Point" ); 152 | ctiRp.setProtocol( "SCCP" ); 153 | ctiRp.setProtocolSide( "User" ); 154 | XFkType devicePoolForeignKey = new XFkType(); 155 | devicePoolForeignKey.setValue( "Default" ); 156 | JAXBElement devicePoolName = objectFactory.createXCtiRoutePointDevicePoolName( devicePoolForeignKey ); 157 | ctiRp.setDevicePoolName( devicePoolName ); 158 | XFkType locationForeignKey = new XFkType(); 159 | locationForeignKey.setValue( "Hub_None" ); 160 | ctiRp.setLocationName( locationForeignKey ); 161 | Lines lines = new Lines(); 162 | // This provides a List object pointing to the array 163 | List linesList = lines.getLineIdentifier(); 164 | XNumplanIdentifier line = new XNumplanIdentifier(); 165 | line.setDirectoryNumber( "9999" ); 166 | line.setRoutePartitionName( null ); 167 | // We can use listLines to manipulate the Lines object, i.e. to add a lineIdentifier 168 | linesList.add( line ); 169 | ctiRp.setLines( lines ); 170 | addCtiRpReq.setCtiRoutePoint( ctiRp ); 171 | 172 | // Execute the request, wrapped in try/catch in case an exception is thrown 173 | try { 174 | 175 | StandardResponse response = axlPort.addCtiRoutePoint( addCtiRpReq ); 176 | 177 | // Dive into the response object's hierarchy to retrieve the value 178 | System.console().format("%nAdded CTI Route Point pkid: " + response.getReturn() + "%n%n"); 179 | 180 | } catch (Exception err) { 181 | 182 | // If an exception occurs, dump the stacktrace to the console 183 | err.printStackTrace(); 184 | } 185 | 186 | System.console().readLine("Press Enter to continue..."); 187 | 188 | // Remove the newly created objects 189 | 190 | // NameAndGUIDRequest type is commonly used for requests 191 | NameAndGUIDRequest removeCtiRpReq = new NameAndGUIDRequest(); 192 | 193 | removeCtiRpReq.setName( "testRoutePoint" ); 194 | 195 | try { 196 | 197 | StandardResponse response = axlPort.removePhone( removeCtiRpReq ); 198 | 199 | System.console().format( "%nRemoved CTI Route Point pkid: " + response.getReturn() + "%n" ); 200 | 201 | } catch (Exception err) { 202 | 203 | err.printStackTrace(); 204 | } 205 | 206 | 207 | RemoveLineReq removeLineReq = new RemoveLineReq(); 208 | 209 | removeLineReq.setPattern( "9999" ); 210 | removeLineReq.setRoutePartitionName( routePartitionName ); 211 | 212 | try { 213 | 214 | StandardResponse response = axlPort.removeLine( removeLineReq ); 215 | 216 | System.console().format( "%nRemoved Line pkid: " + response.getReturn() + "%n%n") ; 217 | 218 | } catch (Exception err) { 219 | 220 | err.printStackTrace(); 221 | } 222 | } 223 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/axlsamples/addMobilityProfile.java: -------------------------------------------------------------------------------- 1 | package com.cisco.axlsamples; 2 | 3 | // Performs , and then AXL API operations 4 | // with some hard-coded values. 5 | 6 | // Copyright (c) 2019 Cisco and/or its affiliates. 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | import java.util.Map; 23 | 24 | import javax.xml.bind.JAXBElement; 25 | import javax.xml.ws.BindingProvider; 26 | 27 | import java.security.cert.X509Certificate; 28 | import java.security.KeyManagementException; 29 | import java.security.NoSuchAlgorithmException; 30 | import java.security.cert.CertificateException; 31 | import javax.net.ssl.SSLContext; 32 | import javax.net.ssl.X509TrustManager; 33 | 34 | // import only the XL package modules needed for this sample 35 | import com.cisco.axlsamples.api.AXLAPIService; 36 | import com.cisco.axlsamples.api.AXLPort; 37 | import com.cisco.axlsamples.api.AddMobilityProfileReq; 38 | import com.cisco.axlsamples.api.NameAndGUIDRequest; 39 | import com.cisco.axlsamples.api.ObjectFactory; 40 | import com.cisco.axlsamples.api.StandardResponse; 41 | import com.cisco.axlsamples.api.XDirn; 42 | import com.cisco.axlsamples.api.XFkType; 43 | import com.cisco.axlsamples.api.XMobilityProfile; 44 | import io.github.cdimascio.dotenv.Dotenv; 45 | 46 | // To import the entire AXL package contents: 47 | // 48 | // import com.cisco.axl.api.*; 49 | 50 | public class addMobilityProfile { 51 | 52 | public static void main(String[] args) { 53 | 54 | // Retrieve environment variables from .env, if present 55 | Dotenv dotenv = Dotenv.load(); 56 | 57 | Boolean debug = dotenv.get( "DEBUG" ).equals( "True" ); 58 | 59 | if ( debug ) { System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true"); } 60 | 61 | // Verify the JVM has a console for user input 62 | if ( System.console() == null ) { 63 | System.err.println( "Error: This sample app requires a console" ); 64 | System.exit( 1 ); 65 | } 66 | 67 | // Instantiate the generated AXL API Service client 68 | AXLAPIService axlService = new AXLAPIService(); 69 | 70 | // Get access to the request context so we can set custom params 71 | AXLPort axlPort = axlService.getAXLPort(); 72 | Map< String, Object > requestContext = ( ( BindingProvider ) axlPort ).getRequestContext(); 73 | 74 | // Set the AXL API endpoint address, user, and password 75 | // for our particular environment in the JAX-WS client. 76 | // Configure these values in .env 77 | requestContext.put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://" + dotenv.get( "CUCM" ) + ":8443/axl/"); 78 | requestContext.put( BindingProvider.USERNAME_PROPERTY, dotenv.get( "AXL_USER" ) ); 79 | requestContext.put( BindingProvider.PASSWORD_PROPERTY, dotenv.get( "AXL_PASSWORD" ) ); 80 | // Enable cookies for AXL authentication session reuse 81 | requestContext.put( BindingProvider.SESSION_MAINTAIN_PROPERTY, true ); 82 | 83 | // Uncomment the section below to disable HTTPS certificate checking, 84 | // otherwise import the CUCM Tomcat certificate - see README.md 85 | 86 | // X509TrustManager[] trustAll = new X509TrustManager[] { new X509TrustManager() { 87 | // public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } 88 | // public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 89 | // public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 90 | // } 91 | // }; 92 | // SSLContext context = SSLContext.getInstance( "TLS" ); 93 | // context.init( null, trustAll, new java.security.SecureRandom() ); 94 | // provider.getRequestContext().put( "com.sun.xml.ws.transport.https.client.SSLSocketFactory", context.getSocketFactory() ); 95 | 96 | // Use a local trust store file to validate HTTPS certificates. 97 | // Requires importing the CUCM Tomcat certificate from CUCM into file certificate/local_truststore, see README.md 98 | System.setProperty( "javax.net.ssl.trustStore", "certificate/cacerts" ); 99 | System.setProperty( "javax.net.ssl.trustStorePassword", "changeit" ); 100 | 101 | // Create an objectFactory for creating AXL specific objects 102 | ObjectFactory objectFactory = new ObjectFactory(); 103 | 104 | // Create a new request object and its sub-objects 105 | // Indentation here attempts to represent the object/sub-object hierarchy 106 | // The AXL schema documentation can help in understanding parent/child 107 | // object relations/types 108 | AddMobilityProfileReq addReq = new AddMobilityProfileReq(); 109 | XMobilityProfile profile = new XMobilityProfile(); 110 | profile.setName("testMobilityProfile"); 111 | profile.setMobileClientCallingOption("Dial via Office Reverse"); 112 | profile.setDvofServiceAccessNumber("1000"); 113 | XDirn dn = new XDirn(); 114 | dn.setPattern("1000"); 115 | XFkType foreignKey = new XFkType(); 116 | foreignKey.setValue(null); 117 | JAXBElement partition = objectFactory.createXDirnRoutePartitionName(foreignKey); 118 | dn.setRoutePartitionName(partition); 119 | profile.setDirn(dn); 120 | JAXBElement callerid = objectFactory.createXMobilityProfileDvorCallerId("1003"); 121 | profile.setDvorCallerId(callerid); 122 | addReq.setMobilityProfile(profile); 123 | 124 | // Execute the request, wrapped in try/catch in case an exception is thrown 125 | try { 126 | 127 | StandardResponse response = axlPort.addMobilityProfile(addReq); 128 | 129 | // Dive into the response object's hierarchy to retrieve the value 130 | System.console().format("%nAdded Mobility Profile pkid: " + response.getReturn() + "%n%n"); 131 | 132 | } catch (Exception err) { 133 | 134 | // If an exception occurs, dump the stacktrace to the console 135 | err.printStackTrace(); 136 | } 137 | 138 | System.console().readLine("Press Enter to continue..."); 139 | 140 | // Remove the newly created mobility profile 141 | 142 | // NameAndGUIDRequest type is commonly used for requests 143 | NameAndGUIDRequest removeReq = new NameAndGUIDRequest(); 144 | 145 | removeReq.setName("testMobilityProfile"); 146 | 147 | try { 148 | 149 | StandardResponse response = axlPort.removeMobilityProfile(removeReq); 150 | 151 | System.console().format("%nRemoved object pkid: " + response.getReturn() + "%n%n"); 152 | 153 | } catch (Exception err) { 154 | 155 | err.printStackTrace(); 156 | } 157 | } 158 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/axlsamples/addPhone.java: -------------------------------------------------------------------------------- 1 | package com.cisco.axlsamples; 2 | 3 | // Performs , then creates a new CTI Port using the line with 4 | // . Finally, and AXL API operations 5 | // are used to clean up. 6 | 7 | // Copyright (c) 2021 Cisco and/or its affiliates. 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | import java.util.Map; 25 | import java.util.List; 26 | 27 | import javax.xml.bind.JAXBElement; 28 | import javax.xml.ws.BindingProvider; 29 | 30 | import java.security.cert.X509Certificate; 31 | import java.security.KeyManagementException; 32 | import java.security.NoSuchAlgorithmException; 33 | import java.security.cert.CertificateException; 34 | import javax.net.ssl.SSLContext; 35 | import javax.net.ssl.X509TrustManager; 36 | 37 | // import only the XL package modules needed for this sample 38 | import com.cisco.axlsamples.api.AXLAPIService; 39 | import com.cisco.axlsamples.api.AXLPort; 40 | import com.cisco.axlsamples.api.AddPhoneReq; 41 | import com.cisco.axlsamples.api.AddLineReq; 42 | import com.cisco.axlsamples.api.NameAndGUIDRequest; 43 | import com.cisco.axlsamples.api.ObjectFactory; 44 | import com.cisco.axlsamples.api.RemoveLineReq; 45 | import com.cisco.axlsamples.api.StandardResponse; 46 | import com.cisco.axlsamples.api.XPhone.Lines; 47 | import com.cisco.axlsamples.api.XLine; 48 | import com.cisco.axlsamples.api.XNumplanIdentifier; 49 | import com.cisco.axlsamples.api.XFkType; 50 | import com.cisco.axlsamples.api.XPhone; 51 | import io.github.cdimascio.dotenv.Dotenv; 52 | 53 | // To import the entire AXL package contents: 54 | // 55 | // import com.cisco.axl.api.*; 56 | 57 | public class addPhone { 58 | 59 | public static void main(String[] args) { 60 | 61 | // Retrieve environment variables from .env, if present 62 | Dotenv dotenv = Dotenv.load(); 63 | 64 | Boolean debug = dotenv.get( "DEBUG" ).equals( "True" ); 65 | 66 | if ( debug ) { 67 | System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true"); 68 | // Increase the dump output permitted size 69 | System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dumpTreshold", "999999"); 70 | } 71 | 72 | // Verify the JVM has a console for user input 73 | if ( System.console() == null ) { 74 | System.err.println( "Error: This sample app requires a console" ); 75 | System.exit( 1 ); 76 | } 77 | 78 | // Instantiate the generated AXL API Service client 79 | AXLAPIService axlService = new AXLAPIService(); 80 | 81 | // Get access to the request context so we can set custom params 82 | AXLPort axlPort = axlService.getAXLPort(); 83 | Map< String, Object > requestContext = ( ( BindingProvider ) axlPort ).getRequestContext(); 84 | 85 | // Set the AXL API endpoint address, user, and password 86 | // for our particular environment in the JAX-WS client. 87 | // Configure these values in .env 88 | requestContext.put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://" + dotenv.get( "CUCM" ) + ":8443/axl/"); 89 | requestContext.put( BindingProvider.USERNAME_PROPERTY, dotenv.get( "AXL_USER" ) ); 90 | requestContext.put( BindingProvider.PASSWORD_PROPERTY, dotenv.get( "AXL_PASSWORD" ) ); 91 | // Enable cookies for AXL authentication session reuse 92 | requestContext.put( BindingProvider.SESSION_MAINTAIN_PROPERTY, true ); 93 | 94 | // Uncomment the section below to disable HTTPS certificate checking, 95 | // otherwise import the CUCM Tomcat certificate - see README.md 96 | 97 | // X509TrustManager[] trustAll = new X509TrustManager[] { new X509TrustManager() { 98 | // public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } 99 | // public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 100 | // public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 101 | // } 102 | // }; 103 | // SSLContext context = SSLContext.getInstance( "TLS" ); 104 | // context.init( null, trustAll, new java.security.SecureRandom() ); 105 | // provider.getRequestContext().put( "com.sun.xml.ws.transport.https.client.SSLSocketFactory", context.getSocketFactory() ); 106 | 107 | // Use a local trust store file to validate HTTPS certificates. 108 | // Requires importing the CUCM Tomcat certificate from CUCM into file certificate/local_truststore, see README.md 109 | System.setProperty( "javax.net.ssl.trustStore", "certificate/cacerts" ); 110 | System.setProperty( "javax.net.ssl.trustStorePassword", "changeit" ); 111 | 112 | // Create an objectFactory for creating AXL specific objects 113 | ObjectFactory objectFactory = new ObjectFactory(); 114 | 115 | // Create a new line, which will be added along with the CTI RP 116 | 117 | AddLineReq addlineReq = new AddLineReq(); 118 | XLine newLine = new XLine(); 119 | newLine.setPattern( "9999" ); 120 | XFkType routePartitionForeignKey = new XFkType(); 121 | routePartitionForeignKey.setValue( null ); 122 | JAXBElement routePartitionName = objectFactory.createXCtiRoutePointDevicePoolName( routePartitionForeignKey ); 123 | newLine.setRoutePartitionName( routePartitionName ); 124 | 125 | addlineReq.setLine( newLine ); 126 | 127 | // Execute the request, wrapped in try/catch in case an exception is thrown 128 | try { 129 | 130 | StandardResponse response = axlPort.addLine( addlineReq ); 131 | 132 | // Dive into the response object's hierarchy to retrieve the value 133 | System.console().format( "%nAdded Line pkid: " + response.getReturn() + "%n%n" ); 134 | 135 | } catch (Exception err) { 136 | 137 | // If an exception occurs, dump the stacktrace to the console 138 | err.printStackTrace(); 139 | } 140 | 141 | System.console().readLine( "Press Enter to continue..." ); 142 | 143 | // Create a new request object and its sub-objects 144 | // Indentation here attempts to represent the object/sub-object hierarchy 145 | // The AXL schema documentation can help in understanding parent/child 146 | // object relations/types 147 | AddPhoneReq addPhoneReq = new AddPhoneReq(); 148 | XPhone phone = new XPhone(); 149 | phone.setName( "testCtiPort" ); 150 | phone.setProduct( "CTI Port" ); 151 | phone.setClazz( "Phone" ); 152 | phone.setProtocol( "SCCP" ); 153 | phone.setProtocolSide( "User" ); 154 | XFkType devicePoolForeignKey = new XFkType(); 155 | devicePoolForeignKey.setValue( "Default" ); 156 | JAXBElement devicePoolName = objectFactory.createXCtiRoutePointDevicePoolName( devicePoolForeignKey ); 157 | phone.setDevicePoolName( devicePoolName ); 158 | XFkType locationForeignKey = new XFkType(); 159 | locationForeignKey.setValue( "Hub_None" ); 160 | phone.setLocationName( locationForeignKey ); 161 | Lines lines = new Lines(); 162 | // This provides a List object pointing to the array 163 | List linesList = lines.getLineIdentifier(); 164 | XNumplanIdentifier line = new XNumplanIdentifier(); 165 | line.setDirectoryNumber( "9999" ); 166 | line.setRoutePartitionName( null ); 167 | // We can use listLines to manipulate the Lines object, i.e. to add a lineIdentifier 168 | linesList.add( line ); 169 | phone.setLines( lines ); 170 | addPhoneReq.setPhone( phone ); 171 | 172 | // Execute the request, wrapped in try/catch in case an exception is thrown 173 | try { 174 | 175 | StandardResponse response = axlPort.addPhone( addPhoneReq ); 176 | 177 | // Dive into the response object's hierarchy to retrieve the value 178 | System.console().format("%nAdded Phone pkid: " + response.getReturn() + "%n%n"); 179 | 180 | } catch (Exception err) { 181 | 182 | // If an exception occurs, dump the stacktrace to the console 183 | err.printStackTrace(); 184 | } 185 | 186 | System.console().readLine("Press Enter to continue..."); 187 | 188 | // Remove the newly created objects 189 | 190 | // NameAndGUIDRequest type is commonly used for requests 191 | NameAndGUIDRequest removePhoneReq = new NameAndGUIDRequest(); 192 | 193 | removePhoneReq.setName( "testCtiPort" ); 194 | 195 | try { 196 | 197 | StandardResponse response = axlPort.removePhone( removePhoneReq ); 198 | 199 | System.console().format( "%nRemoved Phone pkid: " + response.getReturn() + "%n" ); 200 | 201 | } catch (Exception err) { 202 | 203 | err.printStackTrace(); 204 | } 205 | 206 | 207 | RemoveLineReq removeLineReq = new RemoveLineReq(); 208 | 209 | removeLineReq.setPattern( "9999" ); 210 | removeLineReq.setRoutePartitionName( routePartitionName ); 211 | 212 | try { 213 | 214 | StandardResponse response = axlPort.removeLine( removeLineReq ); 215 | 216 | System.console().format( "%nRemoved Line pkid: " + response.getReturn() + "%n%n") ; 217 | 218 | } catch (Exception err) { 219 | 220 | err.printStackTrace(); 221 | } 222 | } 223 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/axlsamples/executeSqlQuery.java: -------------------------------------------------------------------------------- 1 | package com.cisco.axlsamples; 2 | 3 | // Performs a operation for the applicationusers table and extracts 4 | // the name and pkid from the response using the AXL API. 5 | 6 | // Copyright (c) 2019 Cisco and/or its affiliates. 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | import java.util.List; 24 | import java.util.Map; 25 | import java.util.Iterator; 26 | 27 | import javax.xml.ws.BindingProvider; 28 | 29 | import java.security.cert.X509Certificate; 30 | import java.security.KeyManagementException; 31 | import java.security.NoSuchAlgorithmException; 32 | import java.security.cert.CertificateException; 33 | import javax.net.ssl.SSLContext; 34 | import javax.net.ssl.X509TrustManager; 35 | 36 | // Import only the AXL package modules needed for this sample 37 | import com.cisco.axlsamples.api.AXLAPIService; 38 | import com.cisco.axlsamples.api.AXLError_Exception; 39 | import com.cisco.axlsamples.api.AXLPort; 40 | import com.cisco.axlsamples.api.ExecuteSQLQueryReq; 41 | import com.cisco.axlsamples.api.ExecuteSQLQueryRes; 42 | 43 | // To import the entire AXL package contents: 44 | // 45 | // import com.cisco.axlsamples.api.*; 46 | 47 | import io.github.cdimascio.dotenv.Dotenv; 48 | 49 | public class executeSqlQuery { 50 | 51 | public static void main( String[] args ) throws NoSuchAlgorithmException, KeyManagementException, AXLError_Exception { 52 | 53 | // Retrieve environment variables from .env, if present 54 | Dotenv dotenv = Dotenv.load(); 55 | 56 | Boolean debug = dotenv.get( "DEBUG" ).equals( "True" ); 57 | 58 | if ( debug ) { 59 | System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true"); 60 | // Increase the dump output permitted size 61 | System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dumpTreshold", "999999"); 62 | } 63 | 64 | // Verify the JVM has a console for user input 65 | if ( System.console() == null ) { 66 | System.err.println( "Error: This sample app requires a console" ); 67 | System.exit( 1 ); 68 | } 69 | 70 | // Instantiate the generated AXL API Service client 71 | AXLAPIService axlService = new AXLAPIService(); 72 | 73 | // Get access to the request context so we can set custom params 74 | AXLPort axlPort = axlService.getAXLPort(); 75 | Map< String, Object > requestContext = ( ( BindingProvider ) axlPort ).getRequestContext(); 76 | 77 | // Set the AXL API endpoint address, user, and password 78 | // for our particular environment in the JAX-WS client. 79 | // Configure these values in .env 80 | requestContext.put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://" + dotenv.get( "CUCM" ) + ":8443/axl/"); 81 | requestContext.put( BindingProvider.USERNAME_PROPERTY, dotenv.get( "AXL_USER" ) ); 82 | requestContext.put( BindingProvider.PASSWORD_PROPERTY, dotenv.get( "AXL_PASSWORD" ) ); 83 | // Enable cookies for AXL authentication session reuse 84 | requestContext.put( BindingProvider.SESSION_MAINTAIN_PROPERTY, true ); 85 | 86 | // Uncomment the section below to disable HTTPS certificate checking, 87 | // otherwise import the CUCM Tomcat certificate - see README.md 88 | 89 | // X509TrustManager[] trustAll = new X509TrustManager[] { new X509TrustManager() { 90 | // public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } 91 | // public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 92 | // public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 93 | // } 94 | // }; 95 | // SSLContext context = SSLContext.getInstance( "TLS" ); 96 | // context.init( null, trustAll, new java.security.SecureRandom() ); 97 | // provider.getRequestContext().put( "com.sun.xml.ws.transport.https.client.SSLSocketFactory", context.getSocketFactory() ); 98 | 99 | // Use a local trust store file to validate HTTPS certificates. 100 | // Requires importing the CUCM Tomcat certificate from CUCM into file certificate/local_truststore, see README.md 101 | System.setProperty( "javax.net.ssl.trustStore", "certificate/cacerts" ); 102 | System.setProperty( "javax.net.ssl.trustStorePassword", "changeit" ); 103 | 104 | // Create an executeSqlQuery request object 105 | ExecuteSQLQueryReq query = new ExecuteSQLQueryReq(); 106 | 107 | // Set the text of the SQL query 108 | query.setSql( "select name, pkid from applicationuser" ); 109 | 110 | List user_list = null; 111 | 112 | try { 113 | // Prepare a ExecuteSQLQueryRes object to receive the response from AXL 114 | ExecuteSQLQueryRes resp = axlPort.executeSQLQuery( query ); 115 | 116 | // getRow() returns all of the rows as a List type 117 | user_list = resp.getReturn().getRow(); 118 | } catch ( Exception err ) { 119 | // If an exception occurs, dump the stacktrace to the console 120 | err.printStackTrace(); 121 | } 122 | 123 | // Create an iterator to cycle through each row, below 124 | Iterator itr = user_list.iterator(); 125 | 126 | // While the iterator indicates there is at least one more row... 127 | while ( itr.hasNext() ) { 128 | 129 | // The individual row object is of org.w3c.dom.Element type - we'll need to cast from generic Object here 130 | org.w3c.dom.Element el = (org.w3c.dom.Element) itr.next(); 131 | 132 | // Print out the formatted name and pkid values 133 | System.out.println( 134 | "Name: " + String.format( "%-20s", el.getElementsByTagName( "name" ).item( 0 ).getTextContent() )+ 135 | " PKID: " + el.getElementsByTagName( "pkid" ).item( 0 ).getTextContent() 136 | ); 137 | } 138 | 139 | } 140 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/axlsamples/getEnterprisePhoneConfig.java: -------------------------------------------------------------------------------- 1 | package com.cisco.axlsamples; 2 | 3 | // Performs a operation, then parses/prints 4 | // a simple report to the console. 5 | 6 | // Copyright (c) 2019 Cisco and/or its affiliates. 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | import javax.xml.ws.BindingProvider; 27 | 28 | import org.w3c.dom.Element; 29 | import org.w3c.dom.NodeList; 30 | 31 | import java.security.cert.X509Certificate; 32 | import java.security.KeyManagementException; 33 | import java.security.NoSuchAlgorithmException; 34 | import java.security.cert.CertificateException; 35 | import javax.net.ssl.SSLContext; 36 | import javax.net.ssl.X509TrustManager; 37 | 38 | // Import only the AXL package modules needed for this sample 39 | import com.cisco.axlsamples.api.AXLAPIService; 40 | import com.cisco.axlsamples.api.AXLError_Exception; 41 | import com.cisco.axlsamples.api.AXLPort; 42 | import com.cisco.axlsamples.api.GetEnterprisePhoneConfigReq; 43 | import com.cisco.axlsamples.api.GetEnterprisePhoneConfigRes; 44 | 45 | // To import the entire AXL package contents: 46 | // 47 | // import com.cisco.axlsamples.api.*; 48 | 49 | import io.github.cdimascio.dotenv.Dotenv; 50 | 51 | public class getEnterprisePhoneConfig { 52 | 53 | public static void main( String[] args ) throws NoSuchAlgorithmException, KeyManagementException, AXLError_Exception { 54 | 55 | // Retrieve environment variables from .env, if present 56 | Dotenv dotenv = Dotenv.load(); 57 | 58 | Boolean debug = dotenv.get( "DEBUG" ).equals( "True" ); 59 | 60 | if ( debug ) { 61 | System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true"); 62 | // Increase the dump output permitted size 63 | System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dumpTreshold", "999999"); 64 | } 65 | 66 | // Verify the JVM has a console for user input 67 | if ( System.console() == null ) { 68 | System.err.println( "Error: This sample app requires a console" ); 69 | System.exit( 1 ); 70 | } 71 | 72 | // Instantiate the generated AXL API Service client 73 | AXLAPIService axlService = new AXLAPIService(); 74 | 75 | // Get access to the request context so we can set custom params 76 | AXLPort axlPort = axlService.getAXLPort(); 77 | Map< String, Object > requestContext = ( ( BindingProvider ) axlPort ).getRequestContext(); 78 | 79 | // Set the AXL API endpoint address, user, and password 80 | // for our particular environment in the JAX-WS client. 81 | // Configure these values in .env 82 | requestContext.put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://" + dotenv.get( "CUCM" ) + ":8443/axl/"); 83 | requestContext.put( BindingProvider.USERNAME_PROPERTY, dotenv.get( "AXL_USER" ) ); 84 | requestContext.put( BindingProvider.PASSWORD_PROPERTY, dotenv.get( "AXL_PASSWORD" ) ); 85 | // Enable cookies for AXL authentication session reuse 86 | requestContext.put( BindingProvider.SESSION_MAINTAIN_PROPERTY, true ); 87 | 88 | // Uncomment the section below to disable HTTPS certificate checking, 89 | // otherwise import the CUCM Tomcat certificate - see README.md 90 | 91 | // X509TrustManager[] trustAll = new X509TrustManager[] { new X509TrustManager() { 92 | // public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } 93 | // public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 94 | // public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 95 | // } 96 | // }; 97 | // SSLContext context = SSLContext.getInstance( "TLS" ); 98 | // context.init( null, trustAll, new java.security.SecureRandom() ); 99 | // provider.getRequestContext().put( "com.sun.xml.ws.transport.https.client.SSLSocketFactory", context.getSocketFactory() ); 100 | 101 | // Use a local trust store file to validate HTTPS certificates. 102 | // Requires importing the CUCM Tomcat certificate from CUCM into file certificate/local_truststore, see README.md 103 | System.setProperty( "javax.net.ssl.trustStore", "certificate/cacerts" ); 104 | System.setProperty( "javax.net.ssl.trustStorePassword", "changeit" ); 105 | 106 | // Create request/response objects - nothing needs to be configured on the request object 107 | GetEnterprisePhoneConfigReq request = new GetEnterprisePhoneConfigReq(); 108 | GetEnterprisePhoneConfigRes response = null; 109 | 110 | try { 111 | // Execute the request 112 | response = axlPort.getEnterprisePhoneConfig( request ); 113 | 114 | } catch ( Exception err ) { 115 | // If an exception occurs, dump the stacktrace to the console 116 | err.printStackTrace(); 117 | } 118 | 119 | // Extract the vendorConfig contents, which will be a Java List of Element objects 120 | List vendorConfig = response.getReturn().getEnterprisePhoneConfig().getVendorConfig().getValue().getAny(); 121 | 122 | System.out.println( "\nProduct Specific Configuration Layout" ); 123 | System.out.println( "=====================================" ); 124 | 125 | for (Element el : vendorConfig) { 126 | 127 | // If this element's first child contains a text value... 128 | if ( el.getFirstChild().getNodeType() == Element.TEXT_NODE ) { 129 | 130 | System.out.println( el.getTagName() + ": " + el.getFirstChild().getTextContent() ); 131 | } 132 | else { 133 | 134 | // This element contains subelements... 135 | System.out.println( "\n" + el.getTagName() ); 136 | System.out.println( "-".repeat( el.getTagName().length() ) ); 137 | 138 | NodeList children = el.getChildNodes(); 139 | 140 | // Loop through all the child elements and print out the name/value 141 | for ( int i = 0; i < children.getLength()-1; i++ ) { 142 | 143 | System.out.println( "\t" + children.item( i ).getNodeName() + ": " + children.item( i ).getTextContent() ); 144 | } 145 | } 146 | 147 | } 148 | } 149 | 150 | } -------------------------------------------------------------------------------- /src/main/java/com/cisco/axlsamples/getPhone.java: -------------------------------------------------------------------------------- 1 | package com.cisco.axlsamples; 2 | 3 | // Performs a operation and extracts the 'product' type 4 | // using the AXL API. 5 | 6 | // Copyright (c) 2019 Cisco and/or its affiliates. 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | import javax.xml.ws.BindingProvider; 24 | 25 | import java.security.cert.X509Certificate; 26 | import java.util.Map; 27 | import java.security.KeyManagementException; 28 | import java.security.NoSuchAlgorithmException; 29 | import java.security.cert.CertificateException; 30 | import javax.net.ssl.SSLContext; 31 | import javax.net.ssl.X509TrustManager; 32 | 33 | // Import only the AXL package modules needed for this sample 34 | import com.cisco.axlsamples.api.AXLAPIService; 35 | import com.cisco.axlsamples.api.AXLPort; 36 | import com.cisco.axlsamples.api.GetPhoneReq; 37 | import com.cisco.axlsamples.api.GetPhoneRes; 38 | 39 | // Dotenv for Java 40 | import io.github.cdimascio.dotenv.Dotenv; 41 | 42 | // To import the entire AXL package contents: 43 | // 44 | // import com.cisco.axlsamples.api.*; 45 | 46 | public class getPhone { 47 | 48 | public static void main(String[] args) { 49 | 50 | // Retrieve environment variables from .env, if present 51 | Dotenv dotenv = Dotenv.load(); 52 | 53 | Boolean debug = dotenv.get( "DEBUG" ).equals( "True" ); 54 | 55 | if ( debug ) { 56 | System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true"); 57 | // Increase the dump output permitted size 58 | System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dumpTreshold", "999999"); 59 | } 60 | 61 | // Verify the JVM has a console for user input 62 | if (System.console() == null) { 63 | System.err.println("Error: This sample app requires a console"); 64 | System.exit(1); 65 | } 66 | 67 | // Instantiate the generated AXL API Service client 68 | AXLAPIService axlService = new AXLAPIService(); 69 | 70 | // Get access to the request context so we can set custom params 71 | AXLPort axlPort = axlService.getAXLPort(); 72 | Map< String, Object > requestContext = ( ( BindingProvider ) axlPort ).getRequestContext(); 73 | 74 | // Set the AXL API endpoint address, user, and password 75 | // for our particular environment in the JAX-WS client. 76 | // Configure these values in .env 77 | requestContext.put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://" + dotenv.get( "CUCM" ) + ":8443/axl/"); 78 | requestContext.put( BindingProvider.USERNAME_PROPERTY, dotenv.get( "AXL_USER" ) ); 79 | requestContext.put( BindingProvider.PASSWORD_PROPERTY, dotenv.get( "AXL_PASSWORD" ) ); 80 | // Enable cookies for AXL authentication session reuse 81 | requestContext.put( BindingProvider.SESSION_MAINTAIN_PROPERTY, true ); 82 | 83 | // Uncomment the section below to disable HTTPS certificate checking, 84 | // otherwise import the CUCM Tomcat certificate - see README.md 85 | 86 | // X509TrustManager[] trustAll = new X509TrustManager[] { new X509TrustManager() { 87 | // public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } 88 | // public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 89 | // public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { }; 90 | // } 91 | // }; 92 | // SSLContext context = SSLContext.getInstance( "TLS" ); 93 | // context.init( null, trustAll, new java.security.SecureRandom() ); 94 | // provider.getRequestContext().put( "com.sun.xml.ws.transport.https.client.SSLSocketFactory", context.getSocketFactory() ); 95 | 96 | // Use a local trust store file to validate HTTPS certificates. 97 | // Requires importing the CUCM Tomcat certificate from CUCM into file certificate/local_truststore, see README.md 98 | System.setProperty( "javax.net.ssl.trustStore", "certificate/cacerts" ); 99 | System.setProperty( "javax.net.ssl.trustStorePassword", "changeit" ); 100 | 101 | // Create a new request object 102 | GetPhoneReq req = new GetPhoneReq(); 103 | 104 | // Get the device name to retrieve from the user via the console 105 | String phoneName = System.console().readLine("%nPhone device name to retrieve: "); 106 | 107 | req.setName(phoneName); 108 | 109 | // Prepare a GetPhoneRes object to receive the response from AXL 110 | GetPhoneRes getPhoneResponse; 111 | 112 | // Execute the request, wrapped in try/catch in case an exception is thrown 113 | try { 114 | getPhoneResponse = axlPort.getPhone(req); 115 | 116 | // Dive into the response object's hierarchy to retrieve the value 117 | System.console().format("%nPhone product type is: " + 118 | getPhoneResponse.getReturn().getPhone().getProduct() + "%n%n"); 119 | 120 | } catch (Exception err) { 121 | 122 | // If an exception occurs, dump the stacktrace to the console 123 | err.printStackTrace(); 124 | } 125 | } 126 | } --------------------------------------------------------------------------------