cxf如何创建webservice客户端
展开全部
public static void main(String[] args) throws Exception {
//这个是用cxf 客户端访问cxf部署的webservice服务
//千万记住,访问cxf的webservice必须加上namespace ,否则通不过
//现在又另外一个问题,传递过去的参数服务端接收不到
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
org.apache.cxf.endpoint.Client client = dcf.createClient("");
//url为调用webService的wsdl地址
QName name=new QName("","getAlbumList");
//namespace是命名空间,methodName是方法名
String xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ " <facelook>"
+ " <condition>"
+ " <name>家</name>"
+ " <description></description>"
+ " <pageno></pageno>"
+ " <pagesize></pagesize>"
+ " </condition>"
+ " </facelook>";
//paramvalue为参数值
Object[] objects=client.invoke(name,xmlStr);
//调用web Service//输出调用结果
System.out.println(objects[0].toString());
}
//这个是用cxf 客户端访问cxf部署的webservice服务
//千万记住,访问cxf的webservice必须加上namespace ,否则通不过
//现在又另外一个问题,传递过去的参数服务端接收不到
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
org.apache.cxf.endpoint.Client client = dcf.createClient("");
//url为调用webService的wsdl地址
QName name=new QName("","getAlbumList");
//namespace是命名空间,methodName是方法名
String xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ " <facelook>"
+ " <condition>"
+ " <name>家</name>"
+ " <description></description>"
+ " <pageno></pageno>"
+ " <pagesize></pagesize>"
+ " </condition>"
+ " </facelook>";
//paramvalue为参数值
Object[] objects=client.invoke(name,xmlStr);
//调用web Service//输出调用结果
System.out.println(objects[0].toString());
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询