AXL Java UpdatePhoneReq for CUCM 10.5执行时没有错误,但不会更改手机

AXL Java UpdatePhoneReq for CUCM 10.5执行时没有错误,但不会更改手机,java,eclipse,cisco-axl,Java,Eclipse,Cisco Axl,eclipse-AXL-Java新手 我正在慢慢地学习上面的内容 使用JavaSE 1.8和eclipse 4.13.0与运行V10.5的实验室呼叫管理器进行交互, 通过跟踪和修改演示,我能够成功地运行getphone来返回有关手机的信息,包括UUID和描述 从那里我试图添加一个'设置电话'部分,只改变电话描述,然后再次显示电话信息 一切正常,没有错误,但描述从未改变 这是我正在使用的代码: package com.cisco.axl.demo; import javax.xml.bind.

eclipse-AXL-Java新手

我正在慢慢地学习上面的内容

使用JavaSE 1.8和eclipse 4.13.0与运行V10.5的实验室呼叫管理器进行交互, 通过跟踪和修改演示,我能够成功地运行getphone来返回有关手机的信息,包括UUID和描述

从那里我试图添加一个'设置电话'部分,只改变电话描述,然后再次显示电话信息

一切正常,没有错误,但描述从未改变

这是我正在使用的代码:

package com.cisco.axl.demo; 

import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;

/**
 * ------------ AXL DEMO 4 ------------
* Intro - THIS VERSION AXLD3 WORKS on Laptop!!!
*/

import javax.xml.ws.BindingProvider;

import com.cisco.axlapiservice.AXLAPIService;
import com.cisco.axlapiservice.AXLError;
import com.cisco.axlapiservice.AXLPort;
import com.cisco.axl.api._10.*;


/**
* 
 * Performs getPhone operation using AXL API
* 
 * Note, service consumers were generated by the Java 6 wsimport command:
* 
 * <code>
* wsimport -keep -b schema/current/AXLSOAP.xsd -Xnocompile -s src -d bin -verbose schema/current/AXLAPI.ws
* </code>
* 
 * Since AXL uses HTTPS you will have to install the UC application's 
 * Certificate into your keystore in order to run this sample code
* 
 * you can run the program by cd'ing to bin folder within this project and running the following command
* 
 * <code>
* java -cp . com.cisco.axl.demo.Demo
*</code>
*
* it is necessary to install the target systems ssl certificate to all JRE and JDK
* certificate stores - for JREs use:
* "C:\Program Files\Java\jre1.8.0_231\bin\keytool" -import -alias LabCertJre16 -file "C:\Apps\USFEL1-UCL201_corp_pattersoncompanies_com.crt" -keystore "C:\Program Files\Java\jre<VER>\lib\security\jssecacerts"
* 
 * for JDKs use:
* "C:\Program Files\Java\jre1.8.0_231\bin\keytool" -import -alias LabCertJre16 -file "C:\Apps\USFEL1-UCL201_corp_pattersoncompanies_com.crt" -keystore "C:\Program Files\Java\jdk<VER>\jre\lib\security\cacerts"
*
*/

/*
 /*
Things to fix
password is exposed
cert requires fqdn - need to support IP and just server name
warning at beginning
 */

public class Demo {
                /**
                * UC app host.
                */
                protected static String ucHost = null;

                /**
                * OS admin.
                */
                protected static String ucAdmin = null;

                /**
                * OS admin password.
                */
                protected static String ucPswd = null;

                /**
                * New Description.
                */
                protected static String ucDescr = null;

                /**
                * phoneName used in request.
                */
                protected static String phoneName = null;

                /**
                * phoneName used in request.
                */
                protected static String NewDescription = null;

                /**
                 *  UUID returned from getphone - used in setphone
                 */
                protected static String PhoneUUID = null;

                /**
                * Run the demo
                * 
                 * @param args not used
                */
                public static void main(String[] args) {
                                // Verify JVM has a console
                                if (System.console() == null) {
                                                System.err.println("The Cisco AXL Sample App requires a console.");
                                                System.exit(1);
                                } else {
                                                Demo.informUser("%nWelcome to the Cisco AXL Sample APP .%n");
                                }

                                Demo demo = new Demo();
                                demo.getPhoneInfo();



                }

                /**
                * get information about phone
                */
                public void getPhoneInfo() {
                                // Ask for the UC application to upgrade
                                // Demo.informuser("%nWhat UC server would you like to access?%n");
                                ucHost = promptUser("  Host:  ");
                                ucAdmin = promptUser("  OS Admin Account:  ");
                                ucPswd = promptUser("  OS Admin Password:  ");

                                // Ask for the phone name
                                Demo.informUser("%nEnter the name of the phone you want to retrieve information about.%n");
                                phoneName = promptUser("  Phone Name:  ");

                                // Make the getPhoneRequest
                                getPhone();
                                SetPhoneDescr();
                                getPhone();

                }

/**
                   * Makes the getPhone request and displays some of the fields that are returned.
                */
                private void getPhone() 
                                {

                                // Instantiate the wsimport generated AXL API Service client --
                                // see the wsimport comments in the class javadocs above
                                AXLAPIService axlService = new AXLAPIService();
                                AXLPort axlPort = axlService.getAXLPort();


                                // Set the URL, user, and password on the JAX-WS client
                                String validatorUrl = "https://"
                                    + Demo.ucHost
                                    + ":8443/axl/";


                                ((BindingProvider) axlPort).getRequestContext().put(
                                    BindingProvider.ENDPOINT_ADDRESS_PROPERTY, validatorUrl);
                                ((BindingProvider) axlPort).getRequestContext().put(
                                    BindingProvider.USERNAME_PROPERTY, Demo.ucAdmin);
                                ((BindingProvider) axlPort).getRequestContext().put(
                                    BindingProvider.PASSWORD_PROPERTY, Demo.ucPswd);

                                // Create a GetPhoneReq object to represent the getPhone request and set the name of the device
                                //to name entered by user
                                GetPhoneReq axlParams = new GetPhoneReq();
                                axlParams.setName(phoneName);

                                //Make a call to the AXL Service and pass the getPhone request
                                GetPhoneRes getPhoneResponse = null;
                                try {
                                                getPhoneResponse = axlPort.getPhone(axlParams);
                                } catch (AXLError e) {
                                                // TODO Auto-generated catch block
                                                e.printStackTrace();
                                }

                                //display information returned in the response to the user
//                            Demo.informUser("Product=" + getPhoneResponse.getReturn().getPhone().getProduct() + "%n"
//                    + getPhoneResponse.getReturn().getPhone().getLoadInformation().getValue() + "%n");

                                Demo.informUser("Product=" + getPhoneResponse.getReturn().getPhone().getProduct() + "%n");

                                Demo.informUser("Load=" + getPhoneResponse.getReturn().getPhone().getLoadInformation().getValue() + "%n");

                                Demo.informUser("Descr=" + getPhoneResponse.getReturn().getPhone().getDescription()            + "%n");

                                Demo.informUser("Model=" + getPhoneResponse.getReturn().getPhone().getModel()           + "%n");

                                Demo.informUser("Name=" + getPhoneResponse.getReturn().getPhone().getName()          + "%n");

                                PhoneUUID = getPhoneResponse.getReturn().getPhone().getUuid();
                                Demo.informUser("UUID=" + PhoneUUID          + "%n");


                                System.out.println(" ");
                                System.out.println(" ");

                                }


                public void SetPhoneDescr() {



                    // Ask for the new description to apply to the phone
                      ucDescr = promptUser("  NewDescription:  ");


                    // Instantiate the wsimport generated AXL API Service client --
                    // see the wsimport comments in the class javadocs above
                    AXLAPIService axlService = new AXLAPIService();
                    AXLPort axlPort = axlService.getAXLPort();

                    // Set the URL, user, and password on the JAX-WS client
                    String validatorUrl = "https://"
                        + Demo.ucHost
                        + ":8443/axl/";


                    ((BindingProvider) axlPort).getRequestContext().put(
                        BindingProvider.ENDPOINT_ADDRESS_PROPERTY, validatorUrl);
                    ((BindingProvider) axlPort).getRequestContext().put(
                        BindingProvider.USERNAME_PROPERTY, Demo.ucAdmin);
                    ((BindingProvider) axlPort).getRequestContext().put(
                        BindingProvider.PASSWORD_PROPERTY, Demo.ucPswd);



                                // Create a GetPhoneReq object to represent the getPhone request and set the name of the device
                                //to name entered by user
                                UpdatePhoneReq axlParams = new UpdatePhoneReq();
                                axlParams.setNewName(phoneName);
                                axlParams.setDescription(NewDescription);
                                axlParams.setName(phoneName);
                                axlParams.setUuid(PhoneUUID);


                                /**
                                /**
                                 * some test code from devnet Support on JAXBElement

//                                String username = null;
                                String device_uuid = null;

                                axlParams.setUuid(device_uuid);   //.setUuid(device_uuid);
                                    XFkType user = new XFkType(); 
                                    user.setUuid(PhoneUUID);  //returns UserUUID 
                                    JAXBElement<XFkType> user2 = new JAXBElement(new QName(XFkType.class.getSimpleName()), XFkType.class, user);


                                 * end of sample code from devnet
                                 */



                                //Make a call to the AXL Service and pass the getPhone request
                                StandardResponse UpdatePhoneRes = null;
                                try {
                                    UpdatePhoneRes = axlPort.updatePhone(axlParams);
                    } catch (AXLError e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                    }




                }


// -------------------- Some I/O Helper Methods ------------------------

                /**
                * Provide the user some instructions.
    */
                protected static void informUser(String info) {
                                System.console().format(info);
                }


                /**
                * Ask the user a question
                     * @return A non-null, non-empty answer to the question
     */
protected static String promptUser(String question){
   String answer = null;
   while (answer == null || answer.isEmpty()) {
      answer = System.console().readLine(question);
   }
   return answer.trim();
}
}
主要问题是,为什么它不更新描述? 我看到之前的一篇帖子指出我需要调用一个“apply”,但我没有看到一个方法。 当我查看尝试的AXL日志时,它显示为XML:

 <?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:updatePhone xmlns:ns2="http://www.cisco.com/AXL/API/10.5"><name>SEP00AF1F9C5D7A</name><newName>SEP00AF1F9C5D7A</newName></ns2:updatePhone></S:Body></S:Envelope>
SEP00AF1F9C5D7ASEP00AF1F9C5D7A
明确xlParams.setDescription(NewDescription);没有通过参数-很明显我还不知道我在做什么

如果您能在这个问题上给予任何帮助,我们将不胜感激

另外,当我第一次开始处理这个“设置”部分时,我认为我不必再次设置连接,因为它是在“获取”部分设置的。不过,我觉得有必要重复一遍。这是因为它位于getphone部分而不是main部分,还是每次都必须设置它

此外,每次运行它(一次用于get,一次用于集合,然后再次用于第二次get),我都会遇到以下错误:

警告:导入文件:/C:/Users/ME/eclipse workspace/axl demo/schema/current/AXLSoap.xsd违反了BP 1.1 R2001。继续发出警告。 R2001描述必须仅使用WSDL“import”语句来导入另一个WSDL描述

我发现的帖子表明这是web服务本身的问题,而不是我的代码:这是正确的吗?在这种环境下有没有办法抑制它


感谢您的帮助

我猜您在updatePhone请求中同时设置了“name”和“uuid”-它们用于标识目标设备,您应该指定其中一个


查看您的代码,“phoneName”变量可能在这里是空的,可能是AXL忽略了您的(有效)uuid值,并试图用空名称更新目标设备…

我发现了问题。结果是一个简单的编程错误,而不是AXL问题,等等。我在提示用户时填充了一个变量:ucDescr=promptUser(“NewDescription:”)

但是用原始的描述变量更新了手机的构建-所以它可能一直在工作-但是将描述设置回原始值


因此,对于将来发现这个问题的任何人来说——没有什么新奇或神奇的东西——只要检查一下基本知识就可以了

谢谢大卫——在我发布之前,我的屏幕上没有显示你的帖子。对第二个问题有什么想法吗?