0

只是想知道是否有人可以从下面的代码中看到为什么我会收到异常“java.lang.ClassCastException”。

RISService,RisPortType 是我从 WSDL 文件中获取的库,然后使用 wsimport 生成 .java 文件

我知道异常意味着什么,但我只是不确定如何追踪它。

    // Instantiate the wsimport generated SXML API Service client --
    RISService risportService = new RISService();
    RisPortType risportPort = risportService.getRisPort();

    // Set the URL, user, and password on the JAX-WS client
    String hostUrl = "https://10.1.1.1:8443/realtimeservice2/services/RISService";
    ((BindingProvider) risportPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, hostUrl);
    ((BindingProvider) risportPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, cucmDetails.getAxlUsername());
    ((BindingProvider) risportPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, cucmDetails.getAxlPassword());

    // create and populate the selectCmDevice request
    SelectCmDevice sxmlParams = new SelectCmDevice();
    CmSelectionCriteria criteria = new CmSelectionCriteria();
    long maxNum = 200;
    long modelNum = 255;
    ArrayOfSelectItem items = new ArrayOfSelectItem();

    //create a select item criteria to retrieve devices with names matching "SEP123412341234"
    SelectItem item = new SelectItem();
    item.setItem("SEP123412341234");
    items.getItem().add(item);

    //Search on all nodes
    criteria.setNodeName("Any");
    //get back max 200 phones. 9+ can get upto 1000
    criteria.setMaxReturnedDevices(maxNum);
    //get back phones only
    criteria.setDeviceClass("Phone");
    //255 means get back ALL phone models
    criteria.setModel(modelNum);
    //get back only Registered phones
    criteria.setStatus("Registered");
    //return results in order of name
    criteria.setSelectBy("Name");
    //array of phones to get results back for
    criteria.setSelectItems(items);
    sxmlParams.setCmSelectionCriteria(criteria);

    //make selectCmDevice request
    SelectCmDeviceReturn selectResponse = risportPort.selectCmDevice("",criteria); << This is where i get the exception outline below

线程“AWT-EventQueue-0”javax.xml.ws.WebServiceException 中的异常:

java.lang.ClassCastException: [C cannot be cast to java.lang.String
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Unknown Source)
at     com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(Unknown Source)
at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
at com.sun.xml.internal.ws.client.Stub.process(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
at com.sun.proxy.$Proxy40.selectCmDevice(Unknown Source)
at utils._9.APIRIS9.getPhoneIPadd(APIRIS9.java:66)

谢谢亚历克西斯

4

2 回答 2

0

我敢打赌,您的密码将作为 a 返回,char[]而 jaxws 需要一个字符串。

于 2013-06-02T00:25:49.327 回答
0

就我而言

Object port = service.getPort(qname, c);
WSBindingProvider bp = (WSBindingProvider) port;
// Manually set connection timeouts as we seem to hit them during IT testing
Map<String, Object> requestContext = bp.getRequestContext();

requestContext.put(BindingProviderProperties.REQUEST_TIMEOUT, env.getProperty("timeout"));

requestContext.put(BindingProviderProperties.CONNECT_TIMEOUT, env.getProperty("timeout"));

如您所见, requestContext.put() 需要一个字符串和一个对象,您认为设置一个字符串超时会起作用,但是不,java ws 期待一个 int .. 这是一个巨大的问题。

于 2015-03-25T10:08:41.007 回答