Commit 117c4d3a authored by Quxl's avatar Quxl

x

parent 236739a0
...@@ -19,7 +19,6 @@ import org.springframework.stereotype.Component; ...@@ -19,7 +19,6 @@ import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.clients.ServiceFactory; import com.egolm.sso.clients.ServiceFactory;
import com.egolm.sso.clients.ServiceFactory.PasswordType;
import com.egolm.sso.config.XRException; import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService; import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService; import com.egolm.sso.services.TraceService;
...@@ -59,6 +58,9 @@ public class SI004INVENTORYSyncOutServiceTask { ...@@ -59,6 +58,9 @@ public class SI004INVENTORYSyncOutServiceTask {
@Value("${xmlRoot}") @Value("${xmlRoot}")
private String xmlRoot; private String xmlRoot;
@Autowired
private ServiceFactory factory;
@Scheduled(cron="${cronSi004}") @Scheduled(cron="${cronSi004}")
public void execute() throws MalformedURLException { public void execute() throws MalformedURLException {
this.runTask(); this.runTask();
...@@ -70,7 +72,7 @@ public class SI004INVENTORYSyncOutServiceTask { ...@@ -70,7 +72,7 @@ public class SI004INVENTORYSyncOutServiceTask {
File folder = jarFile.getParentFile(); File folder = jarFile.getParentFile();
String absolutePath = folder.getAbsolutePath(); String absolutePath = folder.getAbsolutePath();
String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_004_INVENTORY_SyncOutService.wsdl"; String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_004_INVENTORY_SyncOutService.wsdl";
SI004INVENTORYSyncOut service = ServiceFactory.create(SI004INVENTORYSyncOut.class, wsdlLocation, SI004INVENTORYSyncOutService.SERVICE, SI004INVENTORYSyncOutService.HTTPPort, username, password, PasswordType.PasswordText); SI004INVENTORYSyncOut service = factory.create(SI004INVENTORYSyncOut.class, wsdlLocation, SI004INVENTORYSyncOutService.SERVICE, SI004INVENTORYSyncOutService.HTTPPort);
this.sendData(service); this.sendData(service);
} }
......
...@@ -18,7 +18,6 @@ import org.springframework.stereotype.Component; ...@@ -18,7 +18,6 @@ import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.sso.clients.ServiceFactory; import com.egolm.sso.clients.ServiceFactory;
import com.egolm.sso.clients.ServiceFactory.PasswordType;
import com.egolm.sso.config.XRException; import com.egolm.sso.config.XRException;
import com.egolm.sso.services.CommonService; import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.TraceService; import com.egolm.sso.services.TraceService;
...@@ -58,6 +57,9 @@ public class SI011ACTUALSALESSyncOutServiceTask { ...@@ -58,6 +57,9 @@ public class SI011ACTUALSALESSyncOutServiceTask {
@Value("${xmlRoot}") @Value("${xmlRoot}")
private String xmlRoot; private String xmlRoot;
@Autowired
private ServiceFactory factory;
@Scheduled(cron="${cronSi011}") @Scheduled(cron="${cronSi011}")
public void execute() { public void execute() {
this.runTask(); this.runTask();
...@@ -69,7 +71,7 @@ public class SI011ACTUALSALESSyncOutServiceTask { ...@@ -69,7 +71,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
File folder = jarFile.getParentFile(); File folder = jarFile.getParentFile();
String absolutePath = folder.getAbsolutePath(); String absolutePath = folder.getAbsolutePath();
String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_011_ACTUAL_SALES_SyncOutService.wsdl"; String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/SI_011_ACTUAL_SALES_SyncOutService.wsdl";
SI011ACTUALSALESSyncOut service = ServiceFactory.create(SI011ACTUALSALESSyncOut.class, wsdlLocation, SI011ACTUALSALESSyncOutService.SERVICE, SI011ACTUALSALESSyncOutService.HTTPPort, username, password, PasswordType.PasswordText); SI011ACTUALSALESSyncOut service = factory.create(SI011ACTUALSALESSyncOut.class, wsdlLocation, SI011ACTUALSALESSyncOutService.SERVICE, SI011ACTUALSALESSyncOutService.HTTPPort);
this.sendData(service); this.sendData(service);
} }
......
...@@ -14,33 +14,46 @@ import org.apache.cxf.frontend.ClientProxy; ...@@ -14,33 +14,46 @@ import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; 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.stereotype.Component;
import com.egolm.sso.config.XRException; import com.egolm.sso.config.XRException;
@Component
public class ServiceFactory { public class ServiceFactory {
public static <T> T create(Class<T> requiredType, String wsdlLocation, QName serviceQName, QName portQName, String username, String password, PasswordType passwordType) { @Value("${schneider.username}")
private String username;
@Value("${schneider.password}")
private String password;
public <T> T create(Class<T> requiredType, String wsdlLocation, QName serviceQName, QName portQName) {
assert requiredType != null : "WebService requiredType cannot be null";
assert wsdlLocation != null : "WebService wsdlLocation cannot be null";
assert serviceQName != null : "WebService serviceQName cannot be null";
try { try {
URL WSDL_URL = new URL(wsdlLocation); URL WSDL_URL = new URL(wsdlLocation);
Service dyService = Service.create(WSDL_URL, serviceQName); Service dyService = Service.create(WSDL_URL, serviceQName);
T service = dyService.getPort(portQName, requiredType); T service = portQName == null ? dyService.getPort(requiredType) : dyService.getPort(portQName, requiredType);
ClientProxy.getClient(service).getOutInterceptors().add(getWSS4JOutInterceptor(username, password, passwordType)); ClientProxy.getClient(service).getOutInterceptors().add(getWSS4JOutInterceptor());
return service; return service;
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
throw new XRException(e); throw new XRException(e);
} }
} }
private static WSS4JOutInterceptor wss4JOutInterceptor = null; private WSS4JOutInterceptor wss4JOutInterceptor = null;
public static WSS4JOutInterceptor getWSS4JOutInterceptor(String username, String password, PasswordType passwordType) { public WSS4JOutInterceptor getWSS4JOutInterceptor() {
if(wss4JOutInterceptor == null) { if(wss4JOutInterceptor == null) {
synchronized (wss4JOutInterceptor) { synchronized (wss4JOutInterceptor) {
if(wss4JOutInterceptor == null) { if(wss4JOutInterceptor == null) {
Map<String, Object> pro = new HashMap<String, Object>(); Map<String, Object> pro = new HashMap<String, Object>();
pro.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); pro.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
pro.put(WSHandlerConstants.USER, username); pro.put(WSHandlerConstants.USER, username);
pro.put(WSHandlerConstants.PASSWORD_TYPE, passwordType == null ? PasswordType.PasswordText.name() : passwordType.name()); pro.put(WSHandlerConstants.PASSWORD_TYPE, PasswordType.PasswordText.name());
pro.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() { pro.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
public void handle(Callback[] callbacks) { public void handle(Callback[] callbacks) {
for (int i = 0; i < callbacks.length; i++) { for (int i = 0; i < callbacks.length; i++) {
......
...@@ -17,7 +17,6 @@ import org.springframework.scheduling.annotation.Scheduled; ...@@ -17,7 +17,6 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.egolm.sso.clients.ServiceFactory; import com.egolm.sso.clients.ServiceFactory;
import com.egolm.sso.clients.ServiceFactory.PasswordType;
import com.egolm.sso.clients.Z_MI_SD_009_SO_CREATION.ZDTSD009SOCREATION.Header; import com.egolm.sso.clients.Z_MI_SD_009_SO_CREATION.ZDTSD009SOCREATION.Header;
import com.egolm.sso.clients.Z_MI_SD_009_SO_CREATION.ZDTSD009SOCREATION.ITEM; import com.egolm.sso.clients.Z_MI_SD_009_SO_CREATION.ZDTSD009SOCREATION.ITEM;
import com.egolm.sso.config.XRException; import com.egolm.sso.config.XRException;
...@@ -26,9 +25,9 @@ import com.egolm.sso.services.TraceService; ...@@ -26,9 +25,9 @@ import com.egolm.sso.services.TraceService;
import com.egolm.sso.util.DateUtil; import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.FileUtil; import com.egolm.sso.util.FileUtil;
import com.egolm.sso.util.SqlUtil; import com.egolm.sso.util.SqlUtil;
import com.egolm.sso.util.SqlUtil.Page;
import com.egolm.sso.util.ThrowableUtil; import com.egolm.sso.util.ThrowableUtil;
import com.egolm.sso.util.XMLUtil; import com.egolm.sso.util.XMLUtil;
import com.egolm.sso.util.SqlUtil.Page;
import com.google.gson.Gson; import com.google.gson.Gson;
@Component @Component
...@@ -57,6 +56,9 @@ public class ZMISD009SOCREATIONServiceTask { ...@@ -57,6 +56,9 @@ public class ZMISD009SOCREATIONServiceTask {
@Value("${xmlRoot}") @Value("${xmlRoot}")
private String xmlRoot; private String xmlRoot;
@Autowired
private ServiceFactory factory;
@Scheduled(cron="${cronSap009}") @Scheduled(cron="${cronSap009}")
public void execute() { public void execute() {
this.runTask(); this.runTask();
...@@ -68,7 +70,7 @@ public class ZMISD009SOCREATIONServiceTask { ...@@ -68,7 +70,7 @@ public class ZMISD009SOCREATIONServiceTask {
File folder = jarFile.getParentFile(); File folder = jarFile.getParentFile();
String absolutePath = folder.getAbsolutePath(); String absolutePath = folder.getAbsolutePath();
String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/Z_MI_SD_009_SO_CREATION.wsdl"; String wsdlLocation = "file:///" + absolutePath + "/" + WSDLPATH + "/Z_MI_SD_009_SO_CREATION.wsdl";
ZMISD009SOCREATION service = ServiceFactory.create(ZMISD009SOCREATION.class, wsdlLocation, ZMISD009SOCREATIONService.SERVICE, ZMISD009SOCREATIONService.ZMISD009SOCREATIONPort, username, password, PasswordType.PasswordText); ZMISD009SOCREATION service = factory.create(ZMISD009SOCREATION.class, wsdlLocation, ZMISD009SOCREATIONService.SERVICE, ZMISD009SOCREATIONService.ZMISD009SOCREATIONPort);
this.sendData(service); this.sendData(service);
} }
......
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