CXF - ClassCastException (SEIStub/ClientProxy)

后端 未结 7 1499
时光说笑
时光说笑 2020-12-10 14:05

I\'m trying to build a client jar file to access a webservice. I\'m including the jar in a servlet/war that makes the client webservice calls. I\'m getting the following e

7条回答
  •  囚心锁ツ
    2020-12-10 14:36

    If all else fails, you can use reflection to override the delegate of the service.

            QName qName = new QName(wsTargetNamespace, wsName);
            service = new YourServiceScheduler(loc, qName);
            Field delegateField = Service.class.getDeclaredField("delegate");
            delegateField.setAccessible(true);
            ServiceDelegate previousDelegate = (ServiceDelegate)delegateField.get(service);
            if(!previousDelegate.getClass().getName().contains("cxf")) {
                ServiceDelegate serviceDelegate = ((Provider) Class.forName("org.apache.cxf.jaxws.spi.ProviderImpl").newInstance())
                    .createServiceDelegate(loc, qName, service.getClass());
                log.info("The " + getClass().getSimpleName() + " delegate is changed from " + "[" + previousDelegate + "] to [" +
                    serviceDelegate +
                    "]");
                delegateField.set(service, serviceDelegate);
            }
            port = service.getYourServiceSoap();
    

提交回复
热议问题