代码如下:
@Override
@SuppressWarnings({ "rawtypes", "unchecked"})
public Integer uploadToSites(Long bussinessId,HttpServletRequest request){
List<Attach> attachList = new ArrayList<>();
String[] businessIdArray = new String[1];
businessIdArray[0] = String.valueOf(bussinessId);
Attach at = new Attach();
at.setBusinessTable("tgs_met_info");
at.setBusinessIdArray(businessIdArray);
try {
attachList = attachService.queryAttachByBusinessIds(at);
} catch (Exception e) {
e.printStackTrace();
}
Integer result = -1;
String rt=null;
XmlRpcClientConfigImpl config=new XmlRpcClientConfigImpl();
try {
config.setServerURL(new URL(serverUrl));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
XmlRpcClient client=new XmlRpcClient();
client.setConfig(config);
if(attachList!=null&&attachList.size()>0){
Integer count = 0;
for(Attach attach:attachList){
File orig = new File(request.getSession().getServletContext().getRealPath("/")+filePath+attach.getResourcesName());
Map origData = new HashMap();
origData.put("name", attach.getFileName());
origData.put("type", "image/jpeg");
try {
origData.put("bits", FileUtils.readFileToByteArray(orig));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
origData.put("overwrite", Boolean.TRUE);
Object[] origParams = new Object[]{new Integer(1),"admin","admin",origData};
//远程方法调用
try {
Map resultMap = (Map)client.execute("metaWeblog.newMediaObject", origParams);
rt = ((String)resultMap.get("url")).toString();
if(rt!=null){
count++;
}
if(count==attachList.size()){
result = 1 ;
}
} catch (XmlRpcException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return result;
}
在执行到execute时,抛出异常:
org.apache.xmlrpc.client.XmlRpcClientException:
Failed to parse servers response: 不允许有匹配 "[xX][mM][lL]" 的处理指令目标。
上传成功,不过获取返回值失败,不知道怎么回事,求高人指点