gpt4 book ai didi

java - CUCM 10.5 的 AXL Java UpdatePhoneReq 执行时没有错误,但不会更改电话

转载 作者:行者123 更新时间:2023-12-01 19:36:56 26 4
gpt4 key购买 nike

Eclipse 新手 - AXL - Java

我正在慢慢地学习上述内容。

使用 JavaSE 1.8 和 eclipse 4.13.0 与运行 v 10.5 的实验室调用管理器进行交互,通过跟踪和修改演示,我已经能够成功运行 getphone 以返回有关手机的信息 - 包括 UUID 和描述。

从那里我尝试添加“setphone”部分来仅更改电话描述,然后再次显示电话信息。

一切运行正常,没有错误,但描述永远不会改变。

这是我正在使用的代码:

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>

显然是 xlParams.setDescription(NewDescription);没有传递参数 - 就像我对自己在做什么还不太了解一样。

如果您能就这个问题提供任何帮助,我们将不胜感激。

此外,当我第一次开始处理其中的“设置”部分时,我认为我不必再次设置连接,因为它是在“获取”部分中设置的。但我发现有必要重复一遍。这是因为它位于 getphone 部分而不是主部分,还是必须每次都进行设置?

此外,每次运行它时(一次用于获取,一次用于设置,然后再次运行第二次获取),我都会收到此错误:

警告:导入文件:/C:/Users/ME/eclipse-workspace/axl-demo/schema/current/AXLSoap.xsd 违反了 BP 1.1 R2001。带着警告继续。R2001 描述只能使用 WSDL“导入”语句来导入另一个 WSDL 描述。

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

感谢您的帮助

最佳答案

我的猜测是,您在 updatePhone 请求中同时设置了“name”和“uuid” - 这些用于识别目标设备,您应该指定其中之一。

查看您的代码,“phoneName”变量在这里可能为空,并且 AXL 可能会忽略您的(有效)uuid 值并尝试使用空名称更新目标设备...

关于java - CUCM 10.5 的 AXL Java UpdatePhoneReq 执行时没有错误,但不会更改电话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59206401/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com