WebServiceText.java
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.espeed.text;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
public class WebServiceText {
/**
* @param args
*/
public static void main(String[] args) {
//String url = "http://115.29.230.132:88/webmailWebservice/userinfowebservice?wsdl";
String url="http://localhost:8088/espeedyxyInterface/YXYWebservice/yxycountwebservice?wsdl";
//第一种
// JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
// factory.setServiceClass(WebServiceWsdlInterface.class);
// factory.setAddress(url);
// WebServiceWsdlInterface client = (WebServiceWsdlInterface) factory.create();
// try {
// String a=client.sendWsdlWebService("bbs");
// System.out.println(a);
// }
// catch (Exception e){
// System.out.println("sa");
// }
//第二种
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
org.apache.cxf.endpoint.Client client = dcf.createClient(url);
try {
//第一个参数是要调用的方法名
Object[] result= client.invoke("findcountwebmailhome","info","21gmail.com");
//JSONObject json=JSONObject.fromObject(result);
System.out.println(result[0].toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}