Commit cbe7bd81 authored by Quxl's avatar Quxl

x

parent fdda0922
package com.egolm.sso.clients;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
......@@ -15,6 +16,7 @@ import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.wss4j.common.ext.WSPasswordCallback;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Component;
import com.egolm.sso.config.XRException;
......@@ -29,12 +31,12 @@ public class SAPServiceFactory {
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 wsdlLocation != null : "WebService wsdlLocation cannot be null";
assert WSDLPATH != null : "WebService WSDLPATH cannot be null";
assert serviceQName != null : "WebService serviceQName cannot be null";
try {
URL WSDL_URL = new URL(wsdlLocation);
URL WSDL_URL = new URL(this.getAbsolutePath(WSDLPATH));
Service dyService = Service.create(WSDL_URL, serviceQName);
T service = portQName == null ? dyService.getPort(requiredType) : dyService.getPort(portQName, requiredType);
ClientProxy.getClient(service).getOutInterceptors().add(getWSS4JOutInterceptor());
......@@ -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;
public WSS4JOutInterceptor getWSS4JOutInterceptor() {
......
package com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService;
import java.io.File;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.util.ArrayList;
......@@ -12,7 +11,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
......@@ -52,12 +50,12 @@ public class SI004INVENTORYSyncOutServiceTask {
@Value("${schneider.password}")
private String password;
@Value("${WSDLPATH}")
private String WSDLPATH;
@Value("${xmlRoot}")
private String xmlRoot;
@Value("${WSDL.N004}")
private String WSDLPATH;
@Autowired
private SAPServiceFactory factory;
......@@ -67,12 +65,7 @@ public class SI004INVENTORYSyncOutServiceTask {
}
public void runTask() throws MalformedURLException {
ApplicationHome home = new ApplicationHome(getClass());
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);
SI004INVENTORYSyncOut service = factory.create(SI004INVENTORYSyncOut.class, WSDLPATH, SI004INVENTORYSyncOutService.SERVICE, SI004INVENTORYSyncOutService.HTTPPort);
this.sendData(service);
}
......
package com.egolm.sso.clients.SI_009_SO_CREATION_AsynOutService;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
......@@ -11,7 +10,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
......@@ -50,7 +48,7 @@ public class SI009SOCREATIONAsynOutServiceTask {
@Value("${schneider.password}")
private String password;
@Value("${WSDLPATH}")
@Value("${WSDL.N009}")
private String WSDLPATH;
@Value("${xmlRoot}")
......@@ -65,12 +63,7 @@ public class SI009SOCREATIONAsynOutServiceTask {
}
public void runTask() {
ApplicationHome home = new ApplicationHome(getClass());
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);
SI009SOCREATIONAsynOut service = factory.create(SI009SOCREATIONAsynOut.class, WSDLPATH, SI009SOCREATIONAsynOutService.SERVICE, SI009SOCREATIONAsynOutService.HTTPPort);
this.sendData(service);
}
......
package com.egolm.sso.clients.SI_011_ACTUAL_SALES_SyncOutService;
import java.io.File;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
......@@ -11,7 +10,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
......@@ -51,7 +49,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
@Value("${schneider.password}")
private String password;
@Value("${WSDLPATH}")
@Value("${WSDL.N011}")
private String WSDLPATH;
@Value("${xmlRoot}")
......@@ -66,12 +64,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
}
public void runTask() {
ApplicationHome home = new ApplicationHome(getClass());
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);
SI011ACTUALSALESSyncOut service = factory.create(SI011ACTUALSALESSyncOut.class, WSDLPATH, SI011ACTUALSALESSyncOutService.SERVICE, SI011ACTUALSALESSyncOutService.HTTPPort);
this.sendData(service);
}
......
isUsedTestController: true
xmlRoot: xml
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:
port: 8080
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