axis调用无参数的接口可以,但是一但有参数就出错 错误信息大致是:参数为空,但是我传的值打印出来是有值的。下面附上代码,大佬帮忙看看!谢谢
PS:大致的错误我明白了,这个链接需要两个参数一个data 一个GUID 但是wsdl文件里只有一个data参数!!所以这个GUID只能拼接上去,axis可以拼接吗?在哪个地方拼接
public static String MethodsGeneral(String url,String methods, Map<String, Object> params,String str) {
String GUID="7b33dd14-b183-4d1e-8c96-04baf421498f";
String result="";
try{
String namespace ="http://tempuri.org/";
String soapActionUI = "http://tempuri.org/"+methods;
String endpoint = url;
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setUseSOAPAction(true);
call.setSOAPActionURI(soapActionUI);
call.setOperationName(new QName(namespace,methods));
call.addParameter(new QName(namespace,"data"),org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(namespace,"GUID"),org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
JSONObject jsonObject = new JSONObject(params);
HashMap<String, String> allParam = new HashMap();
String beforeEnc = jsonObject.toString();
String cipherInfo = null;
try {
cipherInfo = AESUtil.encrypt(beforeEnc);
} catch (Exception e) {
e.printStackTrace();
}
// 把加密后的字符串转化为16进制
String temp = StringUtil.str2HexStr(cipherInfo);
//访问的方法名
System.out.println(temp);
System.out.println(GUID);
result = (String)call.invoke(new Object[]{temp,GUID});
}catch(Exception e){
e.printStackTrace();
System.out.println("调用webservice失败!");
}
//將result字符串解析成要用的字符串
return result;
}
以下是错误信息:AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
faultSubcode:
faultString: System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> System.NullReferenceException: 未将对象引用设置到对象的实例。
在 Fuli.WebService.BaseWebService.AESEncrypt(String toEncrypt) 位置 D:\花汇购项目\Backend\Fuli.WebService\BaseWebService.cs:行号 426
在 Fuli.WebService.BaseWebService.GetExceptionReturnInfo(String exMessage) 位置 D:\花汇购项目\Backend\Fuli.WebService\BaseWebService.cs:行号 311
在 Fuli.WebService.UserWebService.GetAddresslistByUsername(String data) 位置 D:\花汇购项目\Backend\Fuli.WebService\UserWebService.asmx.cs:行号 689
--- 内部异常堆栈跟踪的结尾 ---
faultActor:
faultNode:
faultDetail: