JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
org.apache.cxf.endpoint.Client client = dcf.createClien("访问地址");
Object[] obj = new Object[]{};
try {
obj=client.invoke("getMedicalInfo",new Object[]{"test"});
System.out.println(obj[0].toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}这是我调用的方式的客户端,执行是报:java.lang.NoSuchMethodError的错,提示出错的位置在第二行,求指教
org.apache.cxf.endpoint.Client client = dcf.createClien("访问地址");
Object[] obj = new Object[]{};
try {
obj=client.invoke("getMedicalInfo",new Object[]{"test"});
System.out.println(obj[0].toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}这是我调用的方式的客户端,执行是报:java.lang.NoSuchMethodError的错,提示出错的位置在第二行,求指教
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
//指定访问的web service地址
EndpointReference targetEPR = new EndpointReference(
"http://localhost:8080/ws/addition");
options.setTo(targetEPR);
//指定方法,注意指定命名空间
QName opPrint = new QName("http://ws.sis.tpri.com/",
"calculate");
//确定参数类型和参数值
Class[] returnTypes = new Class[] { int.class };
Object obj[] = new Object[] { 7, 85 };
//得到返回结果,是一个数组
Object[] order = serviceClient.invokeBlocking(opPrint, obj,
returnTypes);
System.out.println(order[0]);
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">
<bean id="computerCenter" class="com.tpri.sis.ws.ComputerCenter"
factory-bean="clientFactory" factory-method="create"/>
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.tpri.sis.ws.ComputerCenter"/>
<property name="address" value="http://localhost:8080/ws/calculate"/>
</bean>
</beans>
ClassPathXmlApplicationContext context
= new ClassPathXmlApplicationContext(new String[] {"com/tpri/sis/ws/client-beans.xml"}); ComputerCenter client = (ComputerCenter)context.getBean("computerCenter"); int response = client.calculate(9, 13);
System.out.println("Response: " + response); 这个是Spring+CXF 1楼用的是 axis2