webservice本地调用服务器方法02

private void sendInStockFeedBack(InterfaceOms2CMCC task, String xml, List<WmsSerialNo> snList) {
		Date requestTime = new Date();
		String requestStatus = InterfaceStatus.FINISH;
		StringBuffer requestErrorMsg = new StringBuffer();
		String who = InterfaceWhoException.NONE;

		OpenApiServiceStub stub = null;//通过服务器wsdl文件生成的类
		try {
			stub = new OpenApiServiceStub();
		} catch (AxisFault e) {
			e.printStackTrace();
			requestErrorMsg.append(e.getMessage());
			requestStatus = InterfaceStatus.CLIENT_REMOTE_CMCC_ERROR;
			who = InterfaceWhoException.BOTH;
			commonInterfaceManager.backupMessage4Oms2Cmcc(task.getId(), null, requestTime, "-", null, requestErrorMsg.append("[连接服务器端失败!]").toString(), InterfaceWhoException.BOTH, null, requestStatus);
			return;
		}
		OpenApiServiceStub.WareHouseInfoE whe = null;//通过服务器wsdl文件生成的类
		whe = new OpenApiServiceStub.WareHouseInfoE();
		WareHouseInfo wh = new WareHouseInfo();//通过服务器wsdl文件生成的类
		wh.setDataXml(xml);
		wh.setType("M7007");
		whe.setWareHouseInfo(wh);
		
		InboundDetailResponse2CMCC response = new InboundDetailResponse2CMCC();
		String reponseXML = "-";
		try {
			reponseXML = stub.wareHouseInfo(whe).getWareHouseInfoResponse().get_return();
			if(StringUtils.isEmpty(reponseXML))
				System.out.println("reponse is : "+reponseXML);
		} catch (RemoteException e) {
			e.printStackTrace();
			requestErrorMsg.append(e.getMessage());
			requestStatus = InterfaceStatus.CLIENT_REMOTE_CMCC_ERROR;
			who = InterfaceWhoException.BOTH;
			commonInterfaceManager.backupMessage4Oms2Cmcc(task.getId(), null, null, reponseXML, new Date(), requestErrorMsg.append("[连接服务器端失败!]").toString(), who, null, InterfaceStatus.CLIENT_REMOTE_CMCC_ERROR);
			return;
		}

		try{
			response = new XML2ObjectUtils<InboundDetailResponse2CMCC>().getResponse(reponseXML, new Class[]{InboundDetailResponse2CMCC.class});
		} catch(Exception ex) {
			ex.printStackTrace();
			requestStatus = InterfaceStatus.CLIENT_PARSE_CMCC_XML_ERROR;
			who = InterfaceWhoException.CMCC;
			requestErrorMsg.append(ex.getMessage());
			commonInterfaceManager.backupMessage4Oms2Cmcc(task.getId(), null, null, reponseXML, new Date(), requestErrorMsg.toString(), who, 0, requestStatus);
			return;
		}
		
		if("2".equals(response.getHeaderResponse().getResult())) {
			requestStatus = InterfaceStatus.CLIENT_CMCC_DEAL_RESULT_ERROR;
			who = InterfaceWhoException.BOTH;
			requestErrorMsg.append(response.getHeaderResponse().getResultremark());
		}
		commonInterfaceManager.backupMessage4Oms2Cmcc(task.getId(), null, null, reponseXML, new Date(), requestErrorMsg.toString(), who, null, requestStatus);
		if(snList != null && !snList.isEmpty())
			commonInterfaceManager.storeWmsSerialNoBeSend2CMCC(snList, InterfaceType.OMS_2_CMCC_INBOUND_RESPONSE);
	}

 

你可能感兴趣的:(webservice)