Commit 9fce53b5 authored by Quxl's avatar Quxl

x

parent eb943b53
package com.egolm.sso.clients;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
......@@ -19,8 +18,6 @@ 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;
@Component
public class SAPServiceFactory {
......@@ -32,32 +29,16 @@ public class SAPServiceFactory {
@Value("${schneider.password}")
private String password;
public <T> T create(Class<T> requiredType, String wsdlLocation, QName serviceQName) {
public <T> T create(Class<T> requiredType, URL wsdlLocation, QName serviceQName) {
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 {
URL WSDL_URL = new URL("file:" + wsdlLocation);
Service dyService = Service.create(WSDL_URL, serviceQName);
Service dyService = Service.create(wsdlLocation, serviceQName);
T service = dyService.getPort(requiredType);
ClientProxy.getClient(service).getOutInterceptors().add(getWSS4JOutInterceptor());
return service;
} catch (MalformedURLException e) {
throw new XRException(e);
}
}
// private static String absolutePath = null;
// private String getAbsolutePath(String WSDLPATH) {
// 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() {
......
......@@ -2,6 +2,7 @@ package com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -9,6 +10,7 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.frontend.ClientProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
......@@ -65,7 +67,8 @@ public class SI004INVENTORYSyncOutServiceTask {
}
public void runTask() throws MalformedURLException {
SI004INVENTORYSyncOut service = factory.create(SI004INVENTORYSyncOut.class, WSDLPATH, SI004INVENTORYSyncOutService.SERVICE);
SI004INVENTORYSyncOut service = new SI004INVENTORYSyncOutService(new URL(WSDLPATH)).getPort(SI004INVENTORYSyncOut.class);
ClientProxy.getClient(service).getOutInterceptors().add(factory.getWSS4JOutInterceptor());
this.sendData(service);
}
......
package com.egolm.sso.clients.SI_009_SO_CREATION_AsynOutService;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
......@@ -8,6 +10,7 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.frontend.ClientProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
......@@ -58,12 +61,13 @@ public class SI009SOCREATIONAsynOutServiceTask {
private SAPServiceFactory factory;
@Scheduled(cron="${CRON.N009}")
public void execute() {
public void execute() throws MalformedURLException {
this.runTask();
}
public void runTask() {
SI009SOCREATIONAsynOut service = factory.create(SI009SOCREATIONAsynOut.class, WSDLPATH, SI009SOCREATIONAsynOutService.SERVICE);
public void runTask() throws MalformedURLException {
SI009SOCREATIONAsynOut service = new SI009SOCREATIONAsynOutService(new URL(WSDLPATH)).getPort(SI009SOCREATIONAsynOut.class);
ClientProxy.getClient(service).getOutInterceptors().add(factory.getWSS4JOutInterceptor());
this.sendData(service);
}
......
package com.egolm.sso.clients.SI_011_ACTUAL_SALES_SyncOutService;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -8,6 +10,7 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.frontend.ClientProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
......@@ -59,12 +62,13 @@ public class SI011ACTUALSALESSyncOutServiceTask {
private SAPServiceFactory factory;
@Scheduled(cron="${CRON.N011}")
public void execute() {
public void execute() throws MalformedURLException {
this.runTask();
}
public void runTask() {
SI011ACTUALSALESSyncOut service = factory.create(SI011ACTUALSALESSyncOut.class, WSDLPATH, SI011ACTUALSALESSyncOutService.SERVICE);
public void runTask() throws MalformedURLException {
SI011ACTUALSALESSyncOut service = new SI011ACTUALSALESSyncOutService(new URL(WSDLPATH)).getPort(SI011ACTUALSALESSyncOut.class);
ClientProxy.getClient(service).getOutInterceptors().add(factory.getWSS4JOutInterceptor());
this.sendData(service);
}
......
......@@ -6,9 +6,9 @@ CRON:
N004: 0 20 0 * * ?
N011: 0 30 0 * * ?
WSDL:
N009: WSDL/SI_009_SO_CREATION_AsynOutService.wsdl
N004: WSDL/SI_004_INVENTORY_SyncOutService.wsdl
N011: WSDL/SI_011_ACTUAL_SALES_SyncOutService.wsdl
N009: file:WSDL/SI_009_SO_CREATION_AsynOutService.wsdl
N004: file:WSDL/SI_004_INVENTORY_SyncOutService.wsdl
N011: file: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