SOAPUI調用WebService的三種傳參方式

1.<Request>形式:
舉例:

	public List<RecordEntity> retrieveRecordByPatientNoAndType(String request)
			throws UnsupportedEncodingException {
		Request r=new Request(request);
		String inPatientNo=(String)r.getRequsetParamValue("inPatientNo");
		String code=(String)r.getRequsetParamValue("code");
		String subregion=(String)r.getRequsetParamValue("subregion");
		List<RecordEntity> records = record.retrieveRecordByPatientNoAndType(inPatientNo, code, subregion);
		return records;
	}
此時因爲解析請求方式是Request r=new Request(request);並且參數使用字符串接收;
也就是說SOAPUI傳入參數應爲一個整體,需用到<![CDATA[]]>

		<arg0>
     		<![CDATA[
				<Request>
     				<inPatientNo>1</inPatientNo>
     				<code>420001056</code>
     				<subregion>XXX</subregion>
     			</Request>			
         	]]>
     	</arg0>

2.json格式:
舉例:

public String retrieveAuditForm(String param) {
		long startTime1 = System.currentTimeMillis();
		//返回消息實體
		ResponseMsgData res=new ResponseMsgData();
		//查詢參數
		QueryParamData queryParamData = JSONObject.parseObject(param,QueryParamData.class);
		//用戶名
		String userId = queryParamData.getUserId();
		//轉診單號
		String referNum = queryParamData.getReferNum();
		//轉診申請單開始時間
		String startTime = queryParamData.getStartTime();
		//轉診申請單結束時間
		String endTime = queryParamData.getEndTime();
		//轉診單狀態
		String status = queryParamData.getStatus();
		//患者住院號
		String inPatientNo = queryParamData.getInPatientNo();
		//患者姓名
		String patiName = queryParamData.getPatiName();
		//所屬機構
		String ownOrgCode = queryParamData.getOwnOrgCode();
		
		s_logger.debug("查詢轉診記錄開始 ,方法名爲 retrieveAuditForm,"
				+ "開始時間爲 String startTime1 = 【{}】,"
				+ "參數爲 String userId = 【{}】,"
				+ "String referNum = 【{}】,"
				+ "String startTime = 【{}】,"
				+ "String endTime = 【{}】,"
				+ "String status = 【{}】,"
				+ "String inPatientNo = 【{}】 ,"
				+ "String patiName = 【{}】"
				+ "String ownOrgCode = 【{}】",new Object [] {startTime1,userId,referNum,startTime,
						endTime,status,inPatientNo,patiName,ownOrgCode});
		if(StringUtil.isBlank(userId)) {
			res.setCode(WebServiceConstants.APPLY_USERID_NULL_CODE);
			res.setMsg(WebServiceConstants.APPLY_USERID_NULL_MSG);
		}else {
		List<TransTreatmentApplyFormEntity> trans = applyFormMapper.retrieveTransTreatmentFormList(ownOrgCode, patiName, startTime, endTime, referNum, status, "");
		res.setCode(WebServiceConstants.RESPONSE_SUCCESS_CODE);
		res.setMsg(JSONObject.toJSONString(trans));
		}
		long endTime1 = System.currentTimeMillis();
		String returnString=JSONObject.toJSONString(res);
		s_logger.debug("查詢轉診記錄結束,方法名爲 retrieveAuditForm 結束時間爲 String endTime1 = 【{}】,返回結果爲 String returnString = 【{}】",new Object[] {endTime1,returnString});
		return returnString;
	}
同上,接收類型爲String,並且使用jsonObject進行獲取json字符串的屬性值

     <arg0>
		<![CDATA[
     		{"xxx":"xxx","yyy":"yyyy"}
     	]]>
	 </arg0>

3.xml格式
因爲目前還沒遇到過傳參爲xml格式的,故沒有舉例
入參格式爲:

<![CDATA
	[<?xml version="1.0" encoding="UTF-8"?>
	<root>
		<id>1</id>
		<name>Mike</name>
	</root>
]]>

xml格式參考鏈接:https://blog.csdn.net/u011768325/article/details/50067263

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章