81,092
社区成员
发帖
与我相关
我的任务
分享
public class CallDNet {
public static DynamicClientFactory dcf = DynamicClientFactory.newInstance();
public static org.apache.cxf.endpoint.Client client = dcf
.createClient("http://www.i-pinche.com//handler/PinCheWebServiceMethods.asmx?wsdl");
/**
* @param args
*/
public static void main(String[] args) {
asynchronously();
}
/**
* 异步
*/
public static void asynchronously() {
ClientCallback callback = new ClientCallback();
try {
client.invoke(callback, "GetRoadList");
Map<String, Object> map = callback.getResponseContext();
for (String key : map.keySet()) {
System.out.println(map.get(key));
}
Object[] replys = callback.get();
for (Object o : replys) {
System.out.println(o);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 同步
*/
public static void synchronously() {
Object[] replys = null;
try {
replys = client.invoke("GetRoadList");
} catch (Exception e) {
e.printStackTrace();
}
for (Object o : replys) {
System.out.println(o);
}
}
}
public static void callWebservice() {
try {
URL url = new URL(
"http://XXX.XXX.XXX.XXX/XXX?wsdl");
Client c = new Client(url);
Object[] results = c.invoke("GETDOMINOUSERBYID", new Object[] {
"USERID", "password" }); // 方法名,传递2个参数
Document obj = (Document) results[0];// web service返回的XML对象
if("1".equals(obj.getElementsByTagName("PASSWORD").item(0).getFirstChild().getNodeValue())){
if(obj.getElementsByTagName("SUBJECTLIST").item(0)!=null){
String strMailForm = obj.getElementsByTagName("MAILFROM").item(0).getFirstChild().getNodeValue().toString();
String strPostTime = obj.getElementsByTagName("POSTTIME").item(0).getFirstChild().getNodeValue().toString();
}
}
} catch (Exception e) {
e.printStackTrace();
}