parent
8a349674aa
commit
141692f01d
1 changed files with 117 additions and 0 deletions
@ -0,0 +1,117 @@ |
||||
package org.springblade.plugin.operation.webservice; |
||||
|
||||
import org.springblade.plugin.operation.workorder.entity.InsertTodealByPollCode; |
||||
import org.w3c.dom.Document; |
||||
import org.w3c.dom.NodeList; |
||||
import org.xml.sax.SAXException; |
||||
|
||||
import javax.xml.parsers.DocumentBuilder; |
||||
import javax.xml.parsers.DocumentBuilderFactory; |
||||
import javax.xml.parsers.ParserConfigurationException; |
||||
import java.io.*; |
||||
import java.net.HttpURLConnection; |
||||
import java.net.URL; |
||||
import java.util.UUID; |
||||
|
||||
public class WebServiceUtils { |
||||
|
||||
/** |
||||
* 消息推送 |
||||
* @param code |
||||
*/ |
||||
public static void InsertTodealByPollCode(InsertTodealByPollCode code) { |
||||
|
||||
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + |
||||
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" + |
||||
" <soap:Body>\n" + |
||||
" <InsertTodealByPollCode xmlns=\"http://tempuri.org/\">\n" + |
||||
" <todealGuid>" + code.getTodealGuid() + "</todealGuid>\n" + |
||||
" <fileGuid>" + code.getFileGuid() + "</fileGuid>\n" + |
||||
" <flowGuid>" + code.getFlowGuid() + "</flowGuid>\n" + |
||||
" <title>" + code.getTitle() + "</title>\n" + |
||||
" <docType>" + code.getDocType() + "</docType>\n" + |
||||
" <receiveLocalPerson>" + code.getReceiveLocalPerson() + "</receiveLocalPerson>\n" + |
||||
" <receiveLocalPersonGuid>" + code.getReceiveLocalPersonGuid() + "</receiveLocalPersonGuid>\n" + |
||||
" <sendperson>" + code.getSendperson() + "</sendperson>\n" + |
||||
" <sendpersonGuid>" + code.getSendpersonGuid() + "</sendpersonGuid>\n" + |
||||
" <typeName>" + code.getTypeName() +"</typeName>\n" + |
||||
" <keyNumber>" + code.getKeyNumber() +"</keyNumber>\n" + |
||||
" <isout>" + code.getIsout() +"</isout>\n" + |
||||
" <url>" + code.getUrl() +"</url>\n" + |
||||
" <openFlag>" + code.getOpenFlag() +"</openFlag>\n" + |
||||
" <isReply>" + code.getIsReply() +"</isReply>\n" + |
||||
" <isTop>" + code.getIsTop() +"</isTop>\n" + |
||||
" <fromExchangeCode>"+ code.getFromExchangeCode() +"</fromExchangeCode>\n" + |
||||
" <toExchangeCode>"+ code.getToExchangeCode() +"</toExchangeCode>\n" + |
||||
" <pollCode>"+ code.getPollCode() +"</pollCode>\n" + |
||||
" </InsertTodealByPollCode>\n" + |
||||
" </soap:Body>\n" + |
||||
"</soap:Envelope>\n"; |
||||
|
||||
String url1 = "http://15.72.158.155/jhoa200/OAReceiver/OutersystemOAReceiver.asmx"; |
||||
|
||||
try { |
||||
// 建立Http连接
|
||||
URL obj = new URL(url1); |
||||
HttpURLConnection con = (HttpURLConnection) obj.openConnection(); |
||||
|
||||
// 设置请求方法和请求头
|
||||
con.setRequestMethod("POST"); |
||||
con.setRequestProperty("Content-Type", "text/xml; charset=utf-8"); |
||||
con.setRequestProperty("SOAPAction", "http://tempuri.org/InsertTodealByPollCode"); |
||||
|
||||
// 发送请求体
|
||||
con.setDoOutput(true); |
||||
OutputStream os = con.getOutputStream(); |
||||
os.write(xml.getBytes()); |
||||
os.flush(); |
||||
os.close(); |
||||
|
||||
// 读取响应体
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); |
||||
String inputLine; |
||||
StringBuilder response = new StringBuilder(); |
||||
while ((inputLine = in.readLine()) != null) { |
||||
response.append(inputLine); |
||||
} |
||||
String string = response.toString(); |
||||
in.close(); |
||||
|
||||
// 解析响应体
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
||||
DocumentBuilder builder = factory.newDocumentBuilder(); |
||||
Document doc1 = builder.parse(new ByteArrayInputStream(response.toString().getBytes())); |
||||
NodeList nodeList = doc1.getElementsByTagName("InsertTodealByPollCodeResult"); |
||||
String result = nodeList.item(0).getTextContent(); |
||||
|
||||
// 输出参数值
|
||||
System.out.println("============================================================================"); |
||||
System.out.println("返回值:" + result); |
||||
} catch (IOException | ParserConfigurationException | SAXException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
public static InsertTodealByPollCode getData(InsertTodealByPollCode code) { |
||||
code.setTodealGuid("{" + UUID.randomUUID().toString() + "}"); |
||||
code.setFileGuid("{" + UUID.randomUUID().toString() + "}"); |
||||
code.setFlowGuid(""); |
||||
// code.setTitle("消息推送测试数据");
|
||||
code.setDocType("2"); |
||||
// code.setReceiveLocalPerson("李建国");
|
||||
// code.setReceiveLocalPersonGuid("650390E8-3CE0-47C4-8D4B-5550060944D1");
|
||||
// code.setSendperson("市南区大数据发展中心大数据应用科");
|
||||
// code.setSendpersonGuid("9DEEE6C9-1419-47FF-B76D-4BF3753CC00A");
|
||||
code.setTypeName("其他"); |
||||
code.setKeyNumber(""); |
||||
code.setIsout("1"); |
||||
// code.setUrl("http://10.133.191.105/#/plugin/workflow/process/todo");
|
||||
code.setOpenFlag("1"); |
||||
code.setIsReply("1"); |
||||
code.setIsTop("0"); |
||||
// code.setFromExchangeCode("00020000000000000001");
|
||||
// code.setToExchangeCode("00020000000000000001");
|
||||
code.setPollCode("20051"); |
||||
return code; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue