Commit cbe7bd81 authored by Quxl's avatar Quxl

x

parent fdda0922
package com.egolm.sso.clients; package com.egolm.sso.clients;
import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
...@@ -15,6 +16,7 @@ import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; ...@@ -15,6 +16,7 @@ import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.handler.WSHandlerConstants; import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.wss4j.common.ext.WSPasswordCallback; import org.apache.wss4j.common.ext.WSPasswordCallback;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.egolm.sso.config.XRException; import com.egolm.sso.config.XRException;
...@@ -29,12 +31,12 @@ public class SAPServiceFactory { ...@@ -29,12 +31,12 @@ public class SAPServiceFactory {
private String password; private String password;
public <T> T create(Class<T> requiredType, String wsdlLocation, QName serviceQName, QName portQName) { public <T> T create(Class<T> requiredType, String WSDLPATH, QName serviceQName, QName portQName) {
assert requiredType != null : "WebService requiredType cannot be null"; assert requiredType != null : "WebService requiredType cannot be null";
assert wsdlLocation != null : "WebService wsdlLocation cannot be null"; assert WSDLPATH != null : "WebService WSDLPATH cannot be null";
assert serviceQName != null : "WebService serviceQName cannot be null"; assert serviceQName != null : "WebService serviceQName cannot be null";
try { try {
URL WSDL_URL = new URL(wsdlLocation); URL WSDL_URL = new URL(this.getAbsolutePath(WSDLPATH));
Service dyService = Service.create(WSDL_URL, serviceQName); Service dyService = Service.create(WSDL_URL, serviceQName);
T service = portQName == null ? dyService.getPort(requiredType) : dyService.getPort(portQName, requiredType); T service = portQName == null ? dyService.getPort(requiredType) : dyService.getPort(portQName, requiredType);
ClientProxy.getClient(service).getOutInterceptors().add(getWSS4JOutInterceptor()); ClientProxy.getClient(service).getOutInterceptors().add(getWSS4JOutInterceptor());
...@@ -44,6 +46,22 @@ public class SAPServiceFactory { ...@@ -44,6 +46,22 @@ public class SAPServiceFactory {
} }
} }
private static String absolutePath = null;
private String getAbsolutePath(String WSDLPATH) {
if(absolutePath == null) {
synchronized (absolutePath) {
if(absolutePath == null) {
ApplicationHome home = new ApplicationHome(getClass());
File jarFile = home.getSource();
File folder = jarFile.getParentFile();
absolutePath = folder.getAbsolutePath();
}
}
}
return "file:///" + absolutePath + "/" + WSDLPATH;
}
private WSS4JOutInterceptor wss4JOutInterceptor = null; private WSS4JOutInterceptor wss4JOutInterceptor = null;
public WSS4JOutInterceptor getWSS4JOutInterceptor() { public WSS4JOutInterceptor getWSS4JOutInterceptor() {
......
package com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService; package com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService;
import java.io.File;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -12,7 +11,6 @@ import org.apache.commons.logging.Log; ...@@ -12,7 +11,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -52,12 +50,12 @@ public class SI004INVENTORYSyncOutServiceTask { ...@@ -52,12 +50,12 @@ public class SI004INVENTORYSyncOutServiceTask {
@Value("${schneider.password}") @Value("${schneider.password}")
private String password; private String password;
@Value("${WSDLPATH}")
private String WSDLPATH;
@Value("${xmlRoot}") @Value("${xmlRoot}")
private String xmlRoot; private String xmlRoot;
@Value("${WSDL.N004}")
private String WSDLPATH;
@Autowired @Autowired
private SAPServiceFactory factory; private SAPServiceFactory factory;
...@@ -67,12 +65,7 @@ public class SI004INVENTORYSyncOutServiceTask { ...@@ -67,12 +65,7 @@ public class SI004INVENTORYSyncOutServiceTask {
} }
public void runTask() throws MalformedURLException { public void runTask() throws MalformedURLException {
ApplicationHome home = new ApplicationHome(getClass()); SI004INVENTORYSyncOut service = factory.create(SI004INVENTORYSyncOut.class, WSDLPATH, SI004INVENTORYSyncOutService.SERVICE, SI004INVENTORYSyncOutService.HTTPPort);
File jarFile = home.getSource();
File folder = jarFile.getParentFile();
String absolutePath = folder.getAbsolutePath();
String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_004_INVENTORY_SyncOutService.wsdl";
SI004INVENTORYSyncOut service = factory.create(SI004INVENTORYSyncOut.class, wsdlLocation, SI004INVENTORYSyncOutService.SERVICE, SI004INVENTORYSyncOutService.HTTPPort);
this.sendData(service); this.sendData(service);
} }
......
package com.egolm.sso.clients.SI_009_SO_CREATION_AsynOutService; package com.egolm.sso.clients.SI_009_SO_CREATION_AsynOutService;
import java.io.File;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -11,7 +10,6 @@ import org.apache.commons.logging.Log; ...@@ -11,7 +10,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -50,7 +48,7 @@ public class SI009SOCREATIONAsynOutServiceTask { ...@@ -50,7 +48,7 @@ public class SI009SOCREATIONAsynOutServiceTask {
@Value("${schneider.password}") @Value("${schneider.password}")
private String password; private String password;
@Value("${WSDLPATH}") @Value("${WSDL.N009}")
private String WSDLPATH; private String WSDLPATH;
@Value("${xmlRoot}") @Value("${xmlRoot}")
...@@ -65,12 +63,7 @@ public class SI009SOCREATIONAsynOutServiceTask { ...@@ -65,12 +63,7 @@ public class SI009SOCREATIONAsynOutServiceTask {
} }
public void runTask() { public void runTask() {
ApplicationHome home = new ApplicationHome(getClass()); SI009SOCREATIONAsynOut service = factory.create(SI009SOCREATIONAsynOut.class, WSDLPATH, SI009SOCREATIONAsynOutService.SERVICE, SI009SOCREATIONAsynOutService.HTTPPort);
File jarFile = home.getSource();
File folder = jarFile.getParentFile();
String absolutePath = folder.getAbsolutePath();
String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_009_SO_CREATION_AsynOutService.wsdl";
SI009SOCREATIONAsynOut service = factory.create(SI009SOCREATIONAsynOut.class, wsdlLocation, SI009SOCREATIONAsynOutService.SERVICE, SI009SOCREATIONAsynOutService.HTTPPort);
this.sendData(service); this.sendData(service);
} }
......
package com.egolm.sso.clients.SI_011_ACTUAL_SALES_SyncOutService; package com.egolm.sso.clients.SI_011_ACTUAL_SALES_SyncOutService;
import java.io.File;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -11,7 +10,6 @@ import org.apache.commons.logging.Log; ...@@ -11,7 +10,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -51,7 +49,7 @@ public class SI011ACTUALSALESSyncOutServiceTask { ...@@ -51,7 +49,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
@Value("${schneider.password}") @Value("${schneider.password}")
private String password; private String password;
@Value("${WSDLPATH}") @Value("${WSDL.N011}")
private String WSDLPATH; private String WSDLPATH;
@Value("${xmlRoot}") @Value("${xmlRoot}")
...@@ -66,12 +64,7 @@ public class SI011ACTUALSALESSyncOutServiceTask { ...@@ -66,12 +64,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
} }
public void runTask() { public void runTask() {
ApplicationHome home = new ApplicationHome(getClass()); SI011ACTUALSALESSyncOut service = factory.create(SI011ACTUALSALESSyncOut.class, WSDLPATH, SI011ACTUALSALESSyncOutService.SERVICE, SI011ACTUALSALESSyncOutService.HTTPPort);
File jarFile = home.getSource();
File folder = jarFile.getParentFile();
String absolutePath = folder.getAbsolutePath();
String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_011_ACTUAL_SALES_SyncOutService.wsdl";
SI011ACTUALSALESSyncOut service = factory.create(SI011ACTUALSALESSyncOut.class, wsdlLocation, SI011ACTUALSALESSyncOutService.SERVICE, SI011ACTUALSALESSyncOutService.HTTPPort);
this.sendData(service); this.sendData(service);
} }
......
isUsedTestController: true isUsedTestController: true
xmlRoot: xml xmlRoot: xml
systemId: system systemId: system
WSDLPATH: WSDL WSDL:
N009: WSDL/SI_009_SO_CREATION_AsynOutService.wsdl
N004: WSDL/SI_004_INVENTORY_SyncOutService.wsdl
N011: WSDL/SI_011_ACTUAL_SALES_SyncOutService.wsdl
server: server:
port: 8080 port: 8080
spring: spring:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment