soap方式调用webservice服务demo

--引用参考
【使用Spring ws提供的访问webservice技术】
--Spring的WebServiceTemplate访问WebService的方法及其本质原理
https://blog.csdn.net/kkdelta/article/details/7290769
--spring WebServiceTemplate 调用 axis1.4 发布的webservice
https://www.cnblogs.com/liu-s/p/5677521.html
--几种常用的webservice客户端和spring集成的方法
https://blog.csdn.net/qiuhan/article/details/49487009

    /**
     * 服务接口地址
     */
        @Value("${remote.target.net.gateway.url}")
        private String              serviceUrl;
	@SuppressWarnings("rawtypes")
	public IResult demoFun(List<Integer> paramA, BigDecimal paramB) {
        try {
	    //demo示例--ws soap请求
	    Map<String, Object> map = new HashMap<String, Object>();
            map.put("paramA", paramA);
            map.put("paramB", paramB.toString());
            String json = GsonUtils.toJson(map);
            logger.info("打印请求远程主机接口地址-->{},参数-->{}", serviceUrl, json);
            RemoteAvailableService service = new RemoteAvailableService(new URL(serviceUrl));
            RemoteAvailableServiceSoap soap = service.getRemoteAvailableServiceSoap();
            RequestResult result = soap.doTargetFun(json);
            logger.info("打印请求远程主机接口-->{},返回数据-->{}", "doTargetFun", GsonUtils.toJson(result));
            if (result.getResult() == null) {
                return DefaultResult.fail("******");
            }
	    //com.alibaba.fastjson
            List<Map<String, Object>> list = JSONObject.parseObject(result.getResult().toString(),new TypeReference<List<Map<String, Object>>>(){});
            return DefaultResult.success(list);
        } catch (Exception e) {
            logger.error("******发生错误", e);
            return DefaultResult.fail("******");
        }
    }


其它可参考:
1、用SOAP方式调用webservice
http://jackzlz.iteye.com/blog/1998346

2、WebService中的WSDL详解
http://blog.csdn.net/wenzhi20102321/article/details/68486526

猜你喜欢

转载自franciswmf.iteye.com/blog/2358200