如何使用JAX-WS在AXL Java客户端中使用GetLineReq

时间:2014-07-18 13:17:05

标签: java soap jax-ws cisco-axl

我要做的是使用思科的AXL API从CUCM获取目录号码。这是相关的代码:

private void getNumber(){
    AXLAPIService axlService = new AXLAPIService();
    AXLPort axlPort = axlService.getAXLPort();

    String validatorUrl = "https://mycucm: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);


    GetLineReq axlParams = new GetLineReq();


    axlParams.setPattern("7491817");
    axlParams.setUuid("{48a6ff28-cea7-fc3e-3d82-8cc245ed4ea3}");


    GetLineRes getLineResponse = axlPort.getLine(axlParams);


    Demo.informUser("Line Information: \n" 
            + "Alerting Name: " + getLineResponse.getReturn().getLine().getAlertingName() + "\n" 
            + "Dial Number: " + getLineResponse.getReturn().getLine().getPattern() + "\n" 
            + "Description: " + getLineResponse.getReturn().getLine().getDescription() + "\n"
            + " " + getLineResponse.getReturn().getLine().getShareLineAppearanceCssName());
}

从图中可以看出,只需要指定数字的 uuid 模式

enter image description here

但是代码只有在我指定 uuid 时才有效,而不是,我正在努力实现。我唯一给出的是模式,我想用它来获取所有其他信息。我已经从思科检查了这个网站:How to ... Create an AXL Java Client using JAX-WS

当我遗漏 uuid 时,我收到此错误:

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Item not valid: The specified Line was not found

我还检查了如何使用AXLSqlToolkit将目录号存储在CUCM数据库中:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header/><SOAP-ENV:Body><axl:executeSQLQueryResponse xmlns:axl="http://www.cisco.com/AXL/API/7.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" sequence="1405672933992"><return><row><dnorpattern>7491817</dnorpattern><pkid>48a6ff28-cea7-fc3e-3d82-8cc245ed4ea3</pkid></row></return></axl:executeSQLQueryResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

有没有人知道,我如何才能获得目录号码,只能使用模式 - 值?

1 个答案:

答案 0 :(得分:3)

我自己想通了。 routePartitionName也是必需参数,必须指定。这是我的方法的工作代码:

private void getNumber(){
AXLAPIService axlService = new AXLAPIService();
AXLPort axlPort = axlService.getAXLPort();

String validatorUrl = "https://mycucm: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);


GetLineReq axlParams = new GetLineReq();
ObjectFactory objectFactory = new ObjectFactory(); //This is new

XFkType routePartition = new XFkType(); 
routePartition.setValue("PHONES");     // This is where you specify your route partition name

axlParams.setPattern("7491817");
axlParams.setRoutePartitionName(objectFactory.createGetLineReqRoutePartitionName(routePartition));


GetLineRes getLineResponse = axlPort.getLine(axlParams);


Demo.informUser("Line Information: \n" 
        + "Alerting Name: " + getLineResponse.getReturn().getLine().getAlertingName() + "\n" 
        + "Dial Number: " + getLineResponse.getReturn().getLine().getPattern() + "\n" 
        + "Description: " + getLineResponse.getReturn().getLine().getDescription() + "\n"
        + " " + getLineResponse.getReturn().getLine().getShareLineAppearanceCssName());
}