web service

   @WebService(name = "ElectronicsWebServiceSoap", targetNamespace = "http://tempuri.org/")
    @XmlSeeAlso({ ObjectFactory.class })
    public interface ElectronicsWebServiceSoap {
    	@WebMethod(operationName = "UpdateCartGrade", action = "http://tempuri.org/UpdateCartGrade")
    	@WebResult(name = "UpdateCartGradeResult", targetNamespace = "http://tempuri.org/")
    	@RequestWrapper(localName = "UpdateCartGrade", targetNamespace = "http://tempuri.org/")
    	@ResponseWrapper(localName = "UpdateCartGradeResponse", targetNamespace = "http://tempuri.org/")
    	public String updateCartGrade(@WebParam(name = "version", targetNamespace = "http://tempuri.org/") String version,
    			@WebParam(name = "carno", targetNamespace = "http://tempuri.org/") String carno,
    			@WebParam(name = "pc", targetNamespace = "http://tempuri.org/") int pc,
    			@WebParam(name = "weight", targetNamespace = "http://tempuri.org/") double weight,
    			@WebParam(name = "volume", targetNamespace = "http://tempuri.org/") double volume,
    			@WebParam(name = "guide", targetNamespace = "http://tempuri.org/") String guide,
    			@WebParam(name = "remark", targetNamespace = "http://tempuri.org/") String remark);
    
    }
    @Component
    public class ClientService {
    
    	// @Autowired
    	// private SystemVersion systemVersion;
	private Client client;
	
	private final Logger log = LoggerFactory.getLogger(getClass());

	@Autowired
	private ClientService(SystemVersion systemVersion) throws Exception {
		if (client == null) {
			synchronized (this) {
				if (client == null) {
                	try {
	                	// 创建动态客户端
	        			JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
	        			client = dcf.createClient(systemVersion.getUrl());
                	} catch (Exception e) {
                		log.error("接口连接异常", e);
                		client = null;
                	}
	        	}
			}
		}
	}

	public Client getInstance() {
		return client;
	}
}
public String updateCartGrade(CartGradeReq cartGradeReq) {
	log.info("entry updateCartGrade mehtod ---- ");
	try {
		Client client = clientService.getInstance();
		Endpoint endpoint = client.getEndpoint();
		// 获取方法名所在的包名
		QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), "UpdateCartGrade");
		BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding();
		if (bindingInfo.getOperation(opName) == null) {
			for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) {
				String name = operationInfo.getName().getLocalPart();
				if ("UpdateCartGrade".equals(name)) {
					opName = operationInfo.getName();
					break;
				}
			}
		}

		Object[] objects = null;
		// 调用代理接口的方法调用并返回结果
		objects = client.invoke(opName, new Object[] {httpClient.getVersion(), cartGradeReq.getCarNo(), cartGradeReq.getPc(), cartGradeReq.getWeight(),
				cartGradeReq.getVolume(), cartGradeReq.getGuide(), cartGradeReq.getRemark()});
		BaseHttpRes res = (BaseHttpRes) JSON.parseObject(objects[0].toString(),BaseHttpRes.class);
		if (res.getRetCode() == 100) {
			return "";
		}
	} catch (Exception e) {
		// TODO Auto-generated catch block
		log.error("CartGradeServiceImpl exception : ", e);
	}
	return null;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值