java 通过xml-rpc 调用wordpress的上传图片接口,接口返回失败

代码如下:
@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]" 的处理指令目标。

上传成功,不过获取返回值失败,不知道怎么回事,求高人指点

转载于:https://my.oschina.net/yuans2769/blog/894764

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值