调用webservice服务的几种方式

1.JaxWsDynamicClientFactory 动态调用,只需要指定服务发布的地址、方法名与参数即可;无需关注服务端实现的方式语言。对Spring有着很好的支持。

依赖jar包:

cxf-2.5.4.jar, ,xmlschema-core-2.0.2.jar,,neethi-3.0.2.jar,wsdl4j-1.6.2.jar,,commons-logging-1.1.1.jar


JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
try {
			if (webService == null) {
				webService = dcf.createClient(hisConfig.getWebServiceUri());
			}
		} catch (Exception e) {
			throw new AppException("远程院方服务异常,请联系系统管理员!");
		}
if (webService == null) {
			throw new AppException("初始化远程服务异常,请联系系统管理员!");
		}
try {
			result = webService.invoke(callService, xmlStr);
		} catch (Exception e) {
			webService = null;
			throw new AppException("初始化远程服务异常,请联系系统管理员!" + e.getMessage(), e);
		}
		if (result == null || result.length == 0) {
			throw new AppException("初始化远程服务异常,请联系系统管理员!");
		}
		returnValue = (String) result[0];
		if (StringUtils.isEmpty(returnValue)) {
			throw new AppException("初始化远程服务异常,请联系系统管理员!");
		}

2.AXIS方式

Axis2更像是一种是WS容器,它要求应用程序以aar包的形式部署到自己里面,这对于既有系统,特别是那些基于servlet容器的web应用来说,改造的代价可能会很大。Axis2的优势在于一方面它对WS-*协议族的支持比较全面,另一方面是它还支持C平台,这是一个值得我们关注的优势。


3.下载webservice至本地,这种方式不利于动态调用;服务端一修改,客户端就要从新下载,比较麻烦。

猜你喜欢

转载自blog.csdn.net/qq_33160365/article/details/80055069