现在访问的链接,比如:www.api.com/userid?username=1&guid=1,但是我不知道怎么拼接上去,addParameter两个也不对。请问可以打印出访问的链接吗?或者怎么拼接上去
以下是代码
: public static String MethodsGeneral(String url,String methods,String soapurl, Map params,String str) {
Service service = new Service();
String res=null;
String jsonObjects=null;
Call call;
try {
call = (Call) service.createCall();
call.setTargetEndpointAddress(url);//请求的地址
call.addParameter(str,org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);//设置参数
call.setReturnType(org.apache.axis.encoding.XMLType.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);
allParam.put(str, temp);
call.setOperationName(methods);//访问的方法名
call.setSOAPActionURI(soapurl);//请求头
System.out.println(temp+"&GUID=7b33dd14-b183-4d1e-8c96-04baf421498f");
res=(String) call.invoke(new Object[] {temp});
现在访问的链接,比如:www.api.com/userid?username=1&guid=1,但是我不知道怎么拼接上去,addParameter两个也不对。请问可以打印出访问的链接吗?或者怎么拼接上去
可以自己拼接url 啊, 就是 属性名 = 属性值 ,后台用 & 分割嘛。。。也不是太难
兄弟!在我的印象中调用webservice要么用框架,要么就用Java自动生成webservice的命令,然后直接一行代码直接调用就行
你咋写这么一堆呢。。。
我之前用cxf这个框架的时候,调用更简单,配到spring里然后在业务代码里也是一行代码。。。