• 利用apache-cxf生成webservice本地客户端代码接口及接口的大概调用


    第一步:下载apache-cxf进行环境变量配置

        1、下载apache-cxf-2.6.2在环境变量中配置

        新建CXF_HOME C:ProgramFiles(my)apache-cxf-2.7.2

        在CLASSPATH %CXF_HOME%lib

        在PATH中添加 %CXF_HOME%in
        2、输入cmd 进入控制窗口,输入wsdl2java看是否配置成功

    第二步:生成本地第三方接口本地客户端接口代码

        wsdl2java -encoding utf-8 -d F:\src -client http://hac.haier.net:1033/com.haier.openplatform.hac.resource.service.HacResourceServiceClient?wsdl

        加黑是指定接口代码生成的目录位置,将代码整合到自己项目里。类似这样的代码:

        

     第三步:调用接口

      

    package com.haier.openplatform.hac.resource.service;
    
    import java.util.List;
    
    
    
    
    
    import org.json.JSONObject;
    
    import net.sf.json.JSONArray;
    
    import com.haier.openplatform.hac.service.HacDataPrivilegeDTO;
    import com.haier.openplatform.hac.service.HacPrivilegeServiceClient;
    import com.haier.openplatform.hac.service.HacPrivilegeServiceClientPortType;
    
    public final class Test {
    
        private Test() {
        }
        public static void main(String[] args) {
                HacResourceServiceClient ss = new HacResourceServiceClient();
                HacResourceServiceClientPortType port = ss.getHacResourceServiceClientPort();
                UserSourceAndScode s=new UserSourceAndScode();
                s.setSCode("1.0");
                s.setUserSource("portal");
                List<HacResourceDTO> resourcesByAppAndUser = port.getResourcesByAppAndUser("S00870", "1", "zh_CN", "1.0", s);
                JSONArray json = JSONArray.fromObject(resourcesByAppAndUser); 
                System.out.println(json);
                
              /*  {
                System.out.println("Invoking getResourcesByAppAndUser...");
                for(HacResourceDTO hac:resourcesByAppAndUser){
                     JSONObject json = JSONObject.fromObject(hac);//将java对象转换为json对象
                     String str = json.toString();//将json对象转换为字符串
                     System.out.println(str);
                }*/
               
                
            /*HacPrivilegeServiceClient ss=new HacPrivilegeServiceClient();
            HacPrivilegeServiceClientPortType hacPrivilegeServiceClientPort = ss.getHacPrivilegeServiceClientPort();
            List<HacDataPrivilegeDTO> privilegeData = hacPrivilegeServiceClientPort.getPrivilegeData("", "", null);
            System.out.println("Invoking privilegeData...");
            System.out.println(privilegeData);*/
            }
    }

    大概就是这样

  • 相关阅读:
    20200917-2 词频统计
    20200910-2 博客作业
    20200910-1 每周例行报告
    20200910-3命令行和控制台编程
    使用Requests库实现api接口测试(Python)
    Python Lambda函数的几种使用方法
    文本与向量之间的转换
    Oracle连接出现error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    一图看懂新一代人工智能知识体系大全
    SqlDeveloper连接MySQL出现The connection property ‘zeroDateTimeBehavior’ acceptable values are: ‘CONVERT_TO_NULL’, ‘EXCEPTION’ or ‘ROUND’. The value ‘convertToNull’ is not acceptable 错误
  • 原文地址:https://www.cnblogs.com/dsh2018/p/9486718.html
Copyright © 2020-2023  润新知