0

我正在使用此代码连接服务器,但出现错误:

pms.java:25: error: cannot find symbol
server.setconfig(config);
enter code here   ^
  symbol:   method setconfig(XmlRpcClientConfigImpl)
  location: variable server of type XmlRpcClient



import java.util.*;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
//import org.apache.xmlrpc.client.XmlRpcClientConfig;
import org.apache.xmlrpc.common.*;
import org.apache.xmlrpc.*;
import java.net.*;

public class pms {
    public static void main (String [] args) {

        try {
            String UserName = "123";
            String Password = "123";
            String pKey     = "123";
            Vector params = new Vector();
            params.addElement(UserName);
            params.addElement(Password);
            params.addElement(pKey);
            XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
            config.setServerURL(new URL(" https://wubook.net/xrws/"));
            XmlRpcClient server = new XmlRpcClient();
            server.setconfig(config);

            Object result = server.execute("acquire_token",params);

            System.out.println(result);

            System.out.println("Hello World");
        } catch (Exception e) {
            }
    }

}
4

2 回答 2

0

您的代码 server.setconfig 应该是 setConfig (大写)

于 2017-09-20T08:50:02.000 回答
0

server.setConfig(config)我认为不应该server.setconfig(config)

你可以导入

导入 java.net.URL;导入 java.util.Vector;

导入 org.apache.xmlrpc.client.XmlRpcClient;导入 org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

只有这里是依赖

<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-client</artifactId>
<version>3.1.3</version>

它工作正常,输出在此处输入图像描述

于 2017-09-20T08:47:55.857 回答