importcom.primeton.mq.service.DemoService
importorg.apache.cxf.endpoint.Client
importorg.apache.cxf.jaxws.JaxWsProxyFactoryBean
importorg.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory
importorg.apache.cxf.transport.http.HTTPConduit
importorg.apache.cxf.transports.http.configuration.HTTPClientPolicy
publicclassdemo{
publicstaticvoid main(String[] args) {
//创建动态客户端
JaxWsDynamicClientFactoryfactory =JaxWsDynamicClientFactory.newInstance()
Clientclient = factory.createClient("http://localhost:8090/demo/api?wsdl")
// 需要密码的情况需要加上用户名和密码
//client.getOutInterceptors().add(new ClientLoginInterceptor(USER_NAME,PASS_WORD))
HTTPConduitconduit = (HTTPConduit) client.getConduit()
HTTPClientPolicyhttpClientPolicy = newHTTPClientPolicy()
httpClientPolicy.setConnectionTimeout(2000)//连接超时
httpClientPolicy.setAllowChunking(false)//取消块编码
httpClientPolicy.setReceiveTimeout(120000)//响应超时
conduit.setClient(httpClientPolicy)
//client.getOutInterceptors().addAll(interceptors)//设置拦截器
try{
Object[] objects = newObject[0]
// invoke("方法名",参数1,参数2,参数3....)
objects = client.invoke("sayHello","sujin")
System.out.println("返回数据:"+ objects[0])
}catch(Exceptione){
e.printStackTrace()
}
远程连接oracle 会出现超时连接断开的问题,所以需要修改oracle配置。修改超时时间10分钟
查询修改后的超时时间
其中IDLE_TIME的值就是设置的空闲超时时间。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)