日期:2014-05-19 浏览次数:21406 次
private static final String wsdlUrl = "http://****/services/MyService?wsdl";
private static final String nameSpaceUri = "http://****services/MyService";
private static final String userName="myName";
private static final String password="123456";
private static String callService(String method, String request) {
try {
Service service = new Service();
Call call = null;
call = (Call) service.createCall();
// 调用 getMessage
// System.out.println(">>>getMessage");
call.setOperationName(new QName(nameSpaceUri, method));
call.setTargetEndpointAddress(new java.net.URL(wsdlUrl));
String ret = (String) call.invoke(new Object[] { userName, password,java.net.URLEncoder.encode(request, "UTF-8") });
ret = java.net.URLDecoder.decode(ret, "UTF-8");
JSONObject a = new JSONObject(ret);
System.out.println("return value is " + ret);
return ret;
} catch (Exception e) {
e.printStackTrace();
return "0";
}
}
private static String sendMessage(String phone,String msgContent,String sendTime){
String method="sendMessage";
String phoneParm="destTermId";
String msgParm="msgContent";
String sendTimeParm="sendTime";
JSONObject jsObject = new JSONObject();
try {
jsObject.put(phoneParm, phone);
jsObject.put(msgParm, msgContent);
jsObject.put(sendTimeParm, sendTime);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return callService(method, jsObject.toString());
}
public static void main(String[] args) {
String result = sendMessage("134****5152","This is the message test, said after receipt of normal! Need not ignore! Thank you! [Remote medical treatment] ","");
System.out.println(result);
//System.out.println(getStatus());
//smsRecord();
}
8-22 09:48:49 DEBUG org.apache.axis.client.Call:2445 - Mapping Exception to AxisFault
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.reflect.InvocationTargetException
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:RH-MISP-17
java.lang.reflect.InvocationTargetException
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.