日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Web service client

系統 1694 0

This article is talking about the web service client.

?

Firstly the SOAP message model:


Web service client
?then, the message sample,

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <tns:scheduleRequest xmlns:tns="http://webservice.oo.oo.oo.com">
   <identifier>DSWINV1</identifier>
   <action>SET</action>
   <startDate>TODAY</startDate>
   <startTime>NOW</startTime>
   <interval>600</interval>
   <count>10</count>
   <ignoreMissed>TRUE</ignoreMissed>
   <allowOverwrite>TRUE</allowOverwrite>
  </tns:scheduleRequest>
 </soapenv:Body>
</soapenv:Envelope>
  

?next, the sample code of sending a message,

    public void sendMessage(Message message) throws MalformedURLException,
			SOAPException {
		URL endPoint = new URL(url + serviceName);
		SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();
		SOAPConnection connection = soapConnFactory.createConnection();
		MessageFactory messageFactory = MessageFactory.newInstance();
		// create soap message
		SOAPMessage message = messageFactory.createMessage();
		MimeHeaders mh = message.getMimeHeaders();
		mh.addHeader("SOAPAction", "schedule");
		
		SOAPPart soapPart = message.getSOAPPart();
		SOAPEnvelope envelope = soapPart.getEnvelope();
		SOAPBody body = envelope.getBody();
		SOAPElement requestElement = body.addChildElement("scheduleRequest", NS_PREFIX,
				TARGET_NAMESPACE);
		SOAPElement identifierElement = requestElement.addChildElement("identifier", null);
		identifierElement.addTextNode(schedule.getIdentifier());
		SOAPElement actionElement = requestElement.addChildElement("action", null);
		actionElement.addTextNode(schedule.getAction());	
		SOAPElement startDateElement = requestElement.addChildElement("startDate", null);
		startDateElement.addTextNode(schedule.getStartDate());
		SOAPElement startTimeElement = requestElement.addChildElement("startTime", null);
		startTimeElement.addTextNode(schedule.getStartTime());
		SOAPElement intervalElement = requestElement.addChildElement("interval", null);
		intervalElement.addTextNode(String.valueOf(schedule.getInterval()));
		SOAPElement countElement = requestElement.addChildElement("count", null);
		countElement.addTextNode(String.valueOf(schedule.getCount()));
		SOAPElement ignoreMissedElement = requestElement.addChildElement("ignoreMissed", null);
		ignoreMissedElement.addTextNode(schedule.getIgnoreMissed());
		SOAPElement allowOverwriteElement = requestElement.addChildElement("allowOverwrite", null);
		allowOverwriteElement.addTextNode(schedule.getAllowOverwrite());
		message.saveChanges();
		try {
			message.writeTo(System.out);
		} catch (IOException e) {
			e.printStackTrace();
		}
		SOAPMessage reply = connection.call(message, endPoint);
		try {
			if(reply!=null) reply.writeTo(System.out);
		} catch (IOException e) {
			e.printStackTrace();
		}
		connection.close();
	}
  
?

Web service client


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 连江县| 德江县| 嵊州市| SHOW| 密山市| 横山县| 郴州市| 涟水县| 滦平县| 白山市| 芜湖县| 迭部县| 沂水县| 嘉鱼县| 佳木斯市| 阿坝县| 龙江县| 正阳县| 乌鲁木齐县| 宁化县| 沁阳市| 大悟县| 保德县| 南宫市| 抚宁县| 南城县| 泸水县| 九龙县| 元朗区| 平谷区| 冀州市| 中超| 台南市| 阳新县| 溆浦县| 崇阳县| 安平县| 专栏| 阿拉善盟| 垦利县| 新晃|