代码如下:Java code
Service service = new Service();
try {
Call call = (Call) service.createCall();
String res = "";
String nameSpace = "http: // ktews. com /";
call.setTargetEndpointAddress(new java.net.URL("https: //127.0.0.1 /KTEWS/KTEWS.asmx"));
call.addParameter(new QName(nameSpace, "email"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(nameSpace, "password"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(nameSpace, "serverUrl"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(nameSpace, "amount"),
org.apache.axis.encoding.XMLType.XSD_INT,
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
call.setSOAPActionURI(nameSpace);
call.setOperationName(new QName(nameSpace, "getUnReadEmail"));
res = (String) call.invoke(new Object[] {"test.com", "123456","https: //127.0.0.1 /EWS/exchange.asmx",5});
String[] results = res.split("&");
for(int i = 0 ; i <results.length;i++){
System.out.println(results[i]);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
错误信息如下:
AxisFault
faultCode: {http: // schemas.xmlsoap. org/soap/envelope/}Client
faultSubcode:
faultString: 服务器无法读取请求。 ---> XML 文档(1, 582)中有错误。 ---> 输入字符串的格式不正确。
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:服务器无法读取请求。 ---> XML 文档(1, 582)中有错误。 ---> 输入字符串的格式不正确。