package com;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
/**
* @Description:
* @Author: CC.F
* @Date: 11:58 2019/4/20
*/
public class Test2 {
public static void main(String[] args){
try {
ServiceClient serviceClient = new ServiceClient();
//创建服务地址WebService的URL,注意不是WSDL的URL
String url = "http://192.168.83.1:8976/ICSDesmearWebService.asmx";
EndpointReference targetEPR = new EndpointReference(url);
Options options = serviceClient.getOptions();
options.setTo(targetEPR);
//确定调用方法(wsdl 命名空间地址 (wsdl文档中的targetNamespace) 和 方法名称 的组合)
options.setAction("http://tripod-tech.com/ICS_DesmearWebService");
OMFactory fac = OMAbstractFactory.getOMFactory();
/*
* 指定命名空间,参数:
* uri--即为wsdl文档的targetNamespace,命名空间
* perfix--可不填
*/
OMNamespace omNs = fac.createOMNamespace("http://tripod-tech.com/", "");
// 指定方法
OMElement method = fac.createOMElement("ICS_DesmearWebService", omNs);
// 指定方法的参数
OMElement CompanyCode = fac.createOMElement("CompanyCode", omNs);
CompanyCode.setText("北京");
method.addChild(CompanyCode);
OMElement FactoryId = fac.createOMElement("FactoryId", omNs);
FactoryId.setText("北京");
method.addChild(FactoryId);
OMElement FACTORY_NAME = fac.createOMElement("FACTORY_NAME", omNs);
FACTORY_NAME.setText("北京");
method.addChild(FACTORY_NAME);
OMElement EQP_Group = fac.createOMElement("EQP_Group", omNs);
EQP_Group.setText("北京");
method.addChild(EQP_Group);
OMElement EQP_Code = fac.createOMElement("EQP_Code", omNs);
EQP_Code.setText("北京");
method.addChild(EQP_Code);
OMElement Camera_IP = fac.createOMElement("Camera_IP", omNs);
Camera_IP.setText("北京");
method.addChild(Camera_IP);
OMElement Photo_Time = fac.createOMElement("Photo_Time", omNs);
Photo_Time.setText("北京");
method.addChild(Photo_Time);
OMElement Decision = fac.createOMElement("Decision", omNs);
Decision.setText("北京");
method.addChild(Decision);
OMElement Photo_Address = fac.createOMElement("Photo_Address", omNs);
Photo_Address.setText("北京");
method.addChild(Photo_Address);
method.build();
//远程调用web服务
OMElement result = serviceClient.sendReceive(method);
String xmlStr=result.toString();
System.out.println(xmlStr);
Document document=DocumentHelper.parseText(xmlStr);
Element root=document.getRootElement();
Element ICS_DesmearWebServiceResult=root.element("ICS_DesmearWebServiceResult");
Element RSICS_DesmearWebService=ICS_DesmearWebServiceResult.element("RSICS_DesmearWebService");
Element Result=RSICS_DesmearWebService.element("Result");
Element ResultNotes=RSICS_DesmearWebService.element("ResultNotes");
System.out.println(Result.getText());
System.out.println(ResultNotes.getText());
} catch (Exception axisFault) {
axisFault.printStackTrace();
}
}
}
try {
ServiceClient serviceClient = new ServiceClient();
//创建服务地址WebService的URL,注意不是WSDL的URL
// String url = "http://192.168.83.1:8976/ICSDesmearWebService.asmx";
EndpointReference targetEPR = new EndpointReference(url);
Options options = serviceClient.getOptions();
options.setTo(targetEPR);
//确定调用方法(wsdl 命名空间地址 (wsdl文档中的targetNamespace) 和 方法名称 的组合)
options.setAction(soapAction + webMethod);
OMFactory fac = OMAbstractFactory.getOMFactory();
/*
* 指定命名空间,参数:
* uri--即为wsdl文档的targetNamespace,命名空间
* perfix--可不填
*/
OMNamespace omNs = fac.createOMNamespace(soapAction, "");
// 指定方法
OMElement method = fac.createOMElement(webMethod, omNs);
// 指定方法的参数
OMElement CompanyCode = fac.createOMElement("CompanyCode", omNs);
CompanyCode.setText(deviceRelation.getCompanyCode());
method.addChild(CompanyCode);
webServiceParamsKeys.add("CompanyCode");
OMElement FactoryId = fac.createOMElement("FactoryId", omNs);
FactoryId.setText(deviceRelation.getFactoryId());
method.addChild(FactoryId);
webServiceParamsKeys.add("FactoryId");
OMElement SystemId = fac.createOMElement("SystemId", omNs);
SystemId.setText(deviceRelation.getSystemId());
method.addChild(SystemId);
webServiceParamsKeys.add("SystemId");
OMElement FACTORY_NAME = fac.createOMElement("FACTORY_NAME", omNs);
FACTORY_NAME.setText(deviceRelation.getFactoryName());
method.addChild(FACTORY_NAME);
webServiceParamsKeys.add("FACTORY_NAME");
OMElement EQP_Group = fac.createOMElement("EQP_Group", omNs);
EQP_Group.setText(deviceRelation.getDeviceGroup());
method.addChild(EQP_Group);
webServiceParamsKeys.add("EQP_Group");
OMElement EQP_Code = fac.createOMElement("EQP_Code", omNs);
EQP_Code.setText(deviceRelation.getDeviceCode());
method.addChild(EQP_Code);
webServiceParamsKeys.add("EQP_Code");
OMElement EQP_IP = fac.createOMElement("EQP_IP", omNs);
EQP_IP.setText(deviceRelation.getDeviceIp());
method.addChild(EQP_IP);
webServiceParamsKeys.add("EQP_IP");
OMElement Camera_IP = fac.createOMElement("Camera_IP", omNs);
Camera_IP.setText(deviceRelation.getCameraIp());
method.addChild(Camera_IP);
webServiceParamsKeys.add("Camera_IP");
OMElement Photo_Time = fac.createOMElement("Photo_Time", omNs);
Photo_Time.setText(photoTime);
method.addChild(Photo_Time);
webServiceParamsKeys.add("Photo_Time");
OMElement Decision = fac.createOMElement("Decision", omNs);
Decision.setText(decision);
method.addChild(Decision);
webServiceParamsKeys.add("Decision");
OMElement Photo_Address = fac.createOMElement("Photo_Address", omNs);
Photo_Address.setText(picUrl);
method.addChild(Photo_Address);
webServiceParamsKeys.add("Photo_Address");
method.build();
//远程调用web服务
OMElement result = serviceClient.sendReceive(method);
String xmlStr = result.toString();
logger.info(LogFormatter.toMsg("call webService result:", "result", xmlStr));
try{
Document document = DocumentHelper.parseText(xmlStr);
Element root = document.getRootElement();
Element ICS_DesmearWebServiceResult = root.element("ICS_DesmearWebServiceResult");
Element RSICS_DesmearWebService = ICS_DesmearWebServiceResult.element("RSICS_DesmearWebService");
Element Result = RSICS_DesmearWebService.element("Result");
Element ResultNotes = RSICS_DesmearWebService.element("ResultNotes");
String ResultStr=Result.getText();
String ResultNotesStr=ResultNotes.getText();
}catch (Exception e){
logger.info(LogFormatter.toMsg("result XML error:"), e);
}
2019-04-20T17:00:28.557+08:00 ERROR pcbss.pcbssweb [eventExecutor1] [c.h.pcbss.service.impl.DeviceRelationService:60] - [srcIndex=5fa926822bd44d49a8ac581ce495c63f,deviceIp=192.168.8.189,num=0] updateSrcIndexByDeviceIp failed
2019-04-20T17:00:28.710+08:00 ERROR pcbss.pcbssweb [eventExecutor1] [c.h.pcbss.service.impl.DeviceRelationService:60] - [srcIndex=1674269d535747a0a1e6e8989feb08cc,deviceIp=192.168.8.189,num=0] updateSrcIndexByDeviceIp failed
2019-04-20T17:11:08.123+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:207] - [size=1] eventsVos size:
2019-04-20T17:11:08.332+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:208] - [eventsVos=[{"eventId":"a3e046a6F250416481E2E6E21B6B8576","srcName":"忘放板","eventType":0,"eventOldId":"CDD4FAA2-35A4-403E-AE43-B75DD92B49D5","srcType":"eventRule","timeout":0,"eventDetails":[{"regionIndexCode":"root000000","locationIndexCode":"","srcName":"10.4.22.220","locationName":"","data":{"AIOPResultData":{"confidence":792,"height":"1536","modelID":"f95ef876771548af982295bf5f40fa98","rect":{"h":"0.464844","w":"0.676758","x":"0.219727","y":"0.492839"},"type":1,"valid":1,"visible":1,"width":"2048"},"channelID":33,"dataType":"AIOPDetection","dateTime":"2019-04-20T17:11:07.710+08:00","eventDescription":"AI Open Platform Video Detection","eventType":"AIOP_Video","ipAddress":"192.168.8.189","portNo":8000,"recvTime":"2019-04-20T17:11:07.386+08:00","sendTime":"2019-04-20T17:11:07.395+08:00","targetAttrs":{"cameraIndexCode":"5fa926822bd44d49a8ac581ce495c63f","deviceIndexCode":"4c305a591ee341e9b42819a50b3f96ce","imageServerCode":""},"taskID":"8909220ddb8c4c63b9f4254b213576dd","url":"/pic?=d83ia86e*080i04b-6755c5e5=t1i5m*dp=*7pdi=*1s2i4i5de=*ab8935b6f-80afa71-491038-60za20s=0607d5"},"regionName":"根节点","eventOriginalId":"CDD4FAA2-35A4-403E-AE43-B75DD92B49D5","ability":"event_vss","eventType":422000001,"srcIndex":"5fa926822bd44d49a8ac581ce495c63f","srcType":"camera"}],"eventName":"忘放板","stopTime":1555751467710,"eventLvl":1,"srcIndex":"dbe88da672be4de693e2774614018a99","happenTime":1555751467710,"status":0}]] eventsVos:
2019-04-20T17:11:09.174+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:236] - [eventId=a3e046a6F250416481E2E6E21B6B8576] NO_BOARD
2019-04-20T17:11:09.174+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:672] - [srcIndex=5fa926822bd44d49a8ac581ce495c63f,srcName=10.4.22.220,happenTime=2019/04/20 17:11:07,eventType=忘放板] send to MES start
2019-04-20T17:11:09.195+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:681] - [srcName=10.4.22.220,deviceRelation=DeviceRelation{, id=01975901330e9949619347bc9d5a32707e, srcIndex=null, orderIndex=1, companyCode=CN01, factoryId=C305, systemId=ICS, factoryName=PCB01, deviceLessonName=电镀课, deviceClass=除胶线, deviceGroup=JMDSM, deviceCode=001, deviceIp=机台IP1, cameraIp=10.4.22.220, status=0, createTime=Sat Apr 20 17:00:20 CST 2019, updateTime=null, intRev1=null, strRev1=null}] srcName match device_relation.camera_ip
2019-04-20T17:11:09.228+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.seashell.util.common.PropertyUtil:96] - installPath/D:/Program Files/hikvision/web/components/tomcat85win64.1/webapps/pcbss/WEB-INF/classes/conf/installation.properties
2019-04-20T17:11:09.229+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.seashell.util.common.PropertyUtil:101] - configPathD:/Program Files/hikvision/web/components/pcbss.1/conf/config.properties
2019-04-20T17:11:09.235+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:1039] - [key=webServiceUrl,value=http://wx-ics/ICS_DesmearWebService.asmx] getPackageConfigParam
2019-04-20T17:11:09.237+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:1039] - [key=soapAction,value=http://tripod-tech.com/] getPackageConfigParam
2019-04-20T17:11:09.238+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:1039] - [key=webMethod,value=ICS_DesmearWebService] getPackageConfigParam
2019-04-20T17:11:09.240+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:1039] - [key=webServiceUsername,value=username] getPackageConfigParam
2019-04-20T17:11:09.241+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:1039] - [key=webServicePassword,value=password] getPackageConfigParam
2019-04-20T17:11:09.242+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:1039] - [key=behaviorDecision,value=1:忘放板|2:掉板|3:歪板|4:卡板|5:叠板] getPackageConfigParam
2019-04-20T17:11:09.242+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:1064] - [behaviorDecisionStr=1:忘放板|2:掉板|3:歪板|4:卡板|5:叠板] behaviorDecisionStr:
2019-04-20T17:11:09.316+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:1078] - [webServiceUrl=http://wx-ics/ICS_DesmearWebService.asmx,soapAction=http://tripod-tech.com/,webMethod=ICS_DesmearWebService,webServiceUsername=username,webServicePassword=password,behaviorDecisionMap={卡板=4, 叠板=5, 歪板=3, 掉板=2, 忘放板=1}] initWebServiceParam
2019-04-20T17:11:09.318+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:1039] - [key=needPicFlag,value=true] getPackageConfigParam
2019-04-20T17:11:09.320+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:1078] - [webServiceUrl=http://wx-ics/ICS_DesmearWebService.asmx,soapAction=http://tripod-tech.com/,webMethod=ICS_DesmearWebService,webServiceUsername=username,webServicePassword=password,behaviorDecisionMap={卡板=4, 叠板=5, 歪板=3, 掉板=2, 忘放板=1}] initWebServiceParam
2019-04-20T17:11:09.322+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:817] - [webServiceUrl=http://wx-ics/ICS_DesmearWebService.asmx,soapAction=http://tripod-tech.com/,webMethod=ICS_DesmearWebService,params=[CN01, C305, ICS, PCB01, JMDSM, 001, 机台IP1, 10.4.22.220, 2019/04/20 17:11:07, 2, sorry,this version has no picurl]] call webService start
2019-04-20T17:11:12.073+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:905] - [result={},False 設備資訊錯誤,EAP中不存在! ={}] call webService result:
2019-04-20T17:11:12.221+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:997] - [webServiceParamsKeys=[CompanyCode, FactoryId, SystemId, FACTORY_NAME, EQP_Group, EQP_Code, EQP_IP, Camera_IP, Photo_Time, Decision, Photo_Address]] callWebService paramsKeys
2019-04-20T17:11:12.222+08:00 INFO pcbss.pcbssweb [eventExecutor2] [com.hikvision.pcbss.event.EventDeal:251] - [size=0,jianDingBoardEventList=[]] jianDingBoardEventList:
package com;
/**
* @Description:
* @Author: CC.F
* @Date: 20:11 2019/4/21
*/
public class PicUrl {
public static void main(String[] args) {
String picUrl="https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1555848870&di=ead91b0e2666bc611b2db7a94d3a8950&src=http://img5.duitang.com/uploads/item/201411/12/20141112014133_UXfum.jpeg";
// logger.info(LogFormatter.toMsg("picUrl:", "picUrl", picUrl));
String urlPrefix=null;
if(picUrl.startsWith("https://")){
urlPrefix="https://";
}
if(picUrl.startsWith("http://")){
urlPrefix="http://";
}
String picUrlKey = picUrl.replaceFirst(urlPrefix,"");
picUrlKey=picUrlKey.substring(picUrlKey.indexOf("/"));
String picUrlIp="127.0.0.1:8080";
String photoAddress=urlPrefix+picUrlIp+picUrlKey;
// logger.info(LogFormatter.toMsg("photoAddress:", "photoAddress", photoAddress));
System.out.println(photoAddress);
}
}
package com;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
/**
* @Description:
* @Author: CC.F
* @Date: 20:57 2019/4/21
*/
public class ElementXML {
public static void main(String[] args){
String xmlStr ="False 設備資訊錯誤,EAP中不存在! ";
System.out.println(xmlStr);
try{
Document document = DocumentHelper.parseText(xmlStr);
Element root = document.getRootElement();
Element ICS_DesmearWebServiceResult = root.element("ICS_DesmearWebServiceResult");
Element RSICS_DesmearWebService = ICS_DesmearWebServiceResult.element("RSICS_DesmearWebService");
Element Result = RSICS_DesmearWebService.element("Result");
Element ResultNotes = RSICS_DesmearWebService.element("ResultNotes");
String ResultStr=Result.getText();
String ResultNotesStr=ResultNotes.getText();
System.out.println(ResultStr);
System.out.println(ResultNotesStr);
}catch (Exception e){
// logger.info(LogFormatter.toMsg("result XML error:"), e);
}
}
}