java调用php的api

public static void main(String[] args) {
        String client_id = "100001";
        String sign = "D8C37B7EDD896C3DDFDC156E5ABE95A8";
        String endpoint = "http://dev.vtaoshop.net:80/index.php/Api/wsdl/ws/1";
        // String endpoint = "http://testweb.dev.php/testWebService/testWebService.php";//该段就是上面刚将的地址
        Service service = new Service();
        Call call;
        try {
            call = (Call) service.createCall();
            call.setTargetEndpointAddress(new java.net.URL(endpoint));
            call.setOperationName("get_system_time");

            // String param = new String("安迪".getBytes(),"ISO-8859-1");//如果没有加这段,中文参数将会乱码
            Map map = new HashMap<String, String>();
            map.put("client_id", client_id);
            map.put("sign", sign);
            String s = (String) call.invoke(new Object[] { map });
            s = new String(s.getBytes("ISO-8859-1"));// 如果没有转换编码,中文也会乱码
            System.out.println(s);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

你可能感兴趣的:(java)