zoukankan      html  css  js  c++  java
  • jdk1.6 webService 客户端代码生成和测试

    参数:测试webService的地址:http://10.113.11.1:9090/enocpService/buildingEngService?wsdl

    1,eclipse中新建一个项目,

    2,使用jdk自带wsimport工具自动生成服务端java代码,打开dos窗口,输入 wsimport -keep http://10.23.11.1:8080/webService/buildingEngService?wsdl

         服务端java 代码回自动生成,在当前目录下,只复制两个文件即可。一个是接口BuildingEngService,一个是BuildingEngService_Service,

    3,把生成的两个文件代码复制到项目中,

    4,新建一个java测试类HelloService。

    package com.je.ws;
    
    import java.net.MalformedURLException;
    import java.net.URL;
    
    import javax.xml.namespace.QName;
    import javax.xml.ws.Service;
    
    import cn.com.guodiantong.pb.webservice.server.base.service.BuildingEngService;
    
    public class HelloService {
    
    	    public static void main(String[] args) {
    	    	Service energyService;
    			Class energyTargetInterface = BuildingEngService.class;
    			
    			String url = "http://10.113.11.1:9090/enocpService/buildingEngService";
    			String targetNameSpace = "http://service.base.server.webservice.pb.guodiantong.com.cn/";
    			String interService = "buildingEngService";
    			String targetServicePort = "BuildingEngServicePort";
    			try {
    				energyService = Service.create(new URL(url),new QName(targetNameSpace, interService));
    				QName  energyQname = new QName(targetNameSpace,targetServicePort);
    				BuildingEngService energyPort = energyService.getPort(energyQname, energyTargetInterface);
    				String json = "{"inputFlag":{"systemCode":"BENX","functionCode":"getElectricRecording"},"inputData":[{"deviceNumber":"T1001","electricQuant                            ity":"9784065.00","electricLoad":"2349.90","collectTime":"2016-01-11 14:30:00"}]}";
    				String re = energyPort.getElectricRecording(json);
    				System.out.println("result == "+ re);
    			} catch (MalformedURLException e) {
    				e.printStackTrace();
    			}
    		}
    		
    }
    

      5,Run as java Application  完成。

  • 相关阅读:
    生成8位随机字符串
    Python字符串反转
    dd备份文件系统
    多线程mtr-代码
    Sysctl命令及linux内核参数调整
    解决系统存在大量TIME_WAIT状态的连接
    tcpkill清除异常tcp连接
    graphite
    sed 中带变量的情况
    JAVA的Random类
  • 原文地址:https://www.cnblogs.com/lakelise/p/5121577.html
Copyright © 2011-2022 走看看