Commit 46ffeabe authored by Quxl's avatar Quxl

x

parent 2b3c1ba0
...@@ -18,13 +18,17 @@ import org.apache.wss4j.common.ext.WSPasswordCallback; ...@@ -18,13 +18,17 @@ import org.apache.wss4j.common.ext.WSPasswordCallback;
import com.egolm.sso.config.XRException; import com.egolm.sso.config.XRException;
public class ServiceFactory { public class ServiceFactory {
public static <T> T create(Class<T> requiredType, String wsdlLocation, String namespace, String serviceName, String username, String password) {
return create(requiredType, wsdlLocation, namespace, serviceName, username, password, PasswordType.PasswordText);
}
public static <T> T create(Class<T> requiredType, String wsdlLocation, String namespace, String serviceName, String username, String password, String passwordType) { public static <T> T create(Class<T> requiredType, String wsdlLocation, String namespace, String serviceName, String username, String password, PasswordType passwordType) {
try { try {
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); pro.put(WSHandlerConstants.PASSWORD_TYPE, passwordType == null ? PasswordType.PasswordText.name() : passwordType.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++) {
...@@ -44,4 +48,7 @@ public class ServiceFactory { ...@@ -44,4 +48,7 @@ public class ServiceFactory {
} }
} }
public enum PasswordType {
PasswordText, PasswordNone, PasswordDigest
}
} }
...@@ -7,7 +7,6 @@ import java.util.Date; ...@@ -7,7 +7,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ws.security.WSConstants;
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.boot.system.ApplicationHome;
...@@ -44,7 +43,7 @@ public class ZMISD009SOCREATIONTask { ...@@ -44,7 +43,7 @@ public class ZMISD009SOCREATIONTask {
File folder = jarFile.getParentFile(); File folder = jarFile.getParentFile();
String absolutePath = folder.getAbsolutePath(); String absolutePath = folder.getAbsolutePath();
String wsdlLocation = "file:///" + absolutePath + "/WSDL/Z_MI_SD_009_SO_CREATION.wsdl"; String wsdlLocation = "file:///" + absolutePath + "/WSDL/Z_MI_SD_009_SO_CREATION.wsdl";
ZMISD009SOCREATIONService service = ServiceFactory.create(ZMISD009SOCREATIONService.class, wsdlLocation, "http://schneider-distributor.com/", "Z_MI_SD_009_SO_CREATIONService", username, password, WSConstants.PW_TEXT); ZMISD009SOCREATIONService service = ServiceFactory.create(ZMISD009SOCREATIONService.class, wsdlLocation, "http://schneider-distributor.com/", "Z_MI_SD_009_SO_CREATIONService", username, password);
this.sendData(service.getZMISD009SOCREATIONPort()); this.sendData(service.getZMISD009SOCREATIONPort());
} }
......
...@@ -12,7 +12,7 @@ public class ConfirmQuotationTest { ...@@ -12,7 +12,7 @@ public class ConfirmQuotationTest {
String wsdlLocation = "http://localhost:8080/api/services/confirm_quotation?wsdl"; String wsdlLocation = "http://localhost:8080/api/services/confirm_quotation?wsdl";
String namespace = "http://confirm_quotation.sso.egolm.com"; String namespace = "http://confirm_quotation.sso.egolm.com";
String serviceName = "ConfirmQuotationService"; String serviceName = "ConfirmQuotationService";
ConfirmQuotationService service = ServiceFactory.create(ConfirmQuotationService.class, wsdlLocation, namespace, serviceName, "test", "", "PasswordText"); ConfirmQuotationService service = ServiceFactory.create(ConfirmQuotationService.class, wsdlLocation, namespace, serviceName, "test", "", null);
String XML = StringUtil.readText("D:/data/sso/008-1.XML"); String XML = StringUtil.readText("D:/data/sso/008-1.XML");
Z_MT_SD_008_SO_CONFIRM_QUOTATION Z_MT_SD_008_SO_CONFIRM_QUOTATION = XMLUtil.toBeanByJxab(XML, Z_MT_SD_008_SO_CONFIRM_QUOTATION.class); Z_MT_SD_008_SO_CONFIRM_QUOTATION Z_MT_SD_008_SO_CONFIRM_QUOTATION = XMLUtil.toBeanByJxab(XML, Z_MT_SD_008_SO_CONFIRM_QUOTATION.class);
service.execute(Z_MT_SD_008_SO_CONFIRM_QUOTATION); service.execute(Z_MT_SD_008_SO_CONFIRM_QUOTATION);
......
...@@ -12,7 +12,7 @@ public class DeletionServiceTest { ...@@ -12,7 +12,7 @@ public class DeletionServiceTest {
String wsdlLocation = "http://localhost:8080/api/services/dn_deletion?wsdl"; String wsdlLocation = "http://localhost:8080/api/services/dn_deletion?wsdl";
String namespace = "http://dn_deletion.sso.egolm.com"; String namespace = "http://dn_deletion.sso.egolm.com";
String serviceName = "DNDeletionService"; String serviceName = "DNDeletionService";
DNDeletionService service = ServiceFactory.create(DNDeletionService.class, wsdlLocation, namespace, serviceName, "test", "", "PasswordText"); DNDeletionService service = ServiceFactory.create(DNDeletionService.class, wsdlLocation, namespace, serviceName, "test", "", null);
String XML = StringUtil.readText("D:/data/sso/010.XML"); String XML = StringUtil.readText("D:/data/sso/010.XML");
DELETED_DOCUMENTS DELETED_DOCUMENTS = XMLUtil.toBeanByJxab(XML, DELETED_DOCUMENTS.class); DELETED_DOCUMENTS DELETED_DOCUMENTS = XMLUtil.toBeanByJxab(XML, DELETED_DOCUMENTS.class);
service.execute(DELETED_DOCUMENTS); service.execute(DELETED_DOCUMENTS);
......
...@@ -12,7 +12,7 @@ public class MaterialMasterServiceTest { ...@@ -12,7 +12,7 @@ public class MaterialMasterServiceTest {
String wsdlLocation = "http://10.204.15.9:8080/api/services/material_master?wsdl"; String wsdlLocation = "http://10.204.15.9:8080/api/services/material_master?wsdl";
String namespace = "http://material_master.sso.egolm.com"; String namespace = "http://material_master.sso.egolm.com";
String serviceName = "MaterialMasterService"; String serviceName = "MaterialMasterService";
MaterialMasterService service = ServiceFactory.create(MaterialMasterService.class, wsdlLocation, namespace, serviceName, "test", "", "PasswordText"); MaterialMasterService service = ServiceFactory.create(MaterialMasterService.class, wsdlLocation, namespace, serviceName, "test", "", null);
String XML = StringUtil.readText("D:/data/sso/001.XML"); String XML = StringUtil.readText("D:/data/sso/001.XML");
Z_MT_SD_001_MATERIAL_MASTER Z_MT_SD_001_MATERIAL_MASTER = XMLUtil.toBeanByJxab(XML, Z_MT_SD_001_MATERIAL_MASTER.class); Z_MT_SD_001_MATERIAL_MASTER Z_MT_SD_001_MATERIAL_MASTER = XMLUtil.toBeanByJxab(XML, Z_MT_SD_001_MATERIAL_MASTER.class);
service.execute(Z_MT_SD_001_MATERIAL_MASTER); service.execute(Z_MT_SD_001_MATERIAL_MASTER);
......
...@@ -12,7 +12,7 @@ public class PrformaInvoiceServiceTest { ...@@ -12,7 +12,7 @@ public class PrformaInvoiceServiceTest {
String wsdlLocation = "http://localhost:8080/api/services/prforma_invoice?wsdl"; String wsdlLocation = "http://localhost:8080/api/services/prforma_invoice?wsdl";
String namespace = "http://prforma_invoice.sso.egolm.com"; String namespace = "http://prforma_invoice.sso.egolm.com";
String serviceName = "PrformaInvoiceService"; String serviceName = "PrformaInvoiceService";
PrformaInvoiceService service = ServiceFactory.create(PrformaInvoiceService.class, wsdlLocation, namespace, serviceName, "test", "", "PasswordText"); PrformaInvoiceService service = ServiceFactory.create(PrformaInvoiceService.class, wsdlLocation, namespace, serviceName, "test", "");
String XML = StringUtil.readText("D:/data/sso/005.XML"); String XML = StringUtil.readText("D:/data/sso/005.XML");
Z_MT_SD_005_PERFORM_INVOICE Z_MT_SD_005_PERFORM_INVOICE = XMLUtil.toBeanByJxab(XML, Z_MT_SD_005_PERFORM_INVOICE.class); Z_MT_SD_005_PERFORM_INVOICE Z_MT_SD_005_PERFORM_INVOICE = XMLUtil.toBeanByJxab(XML, Z_MT_SD_005_PERFORM_INVOICE.class);
service.execute(Z_MT_SD_005_PERFORM_INVOICE); service.execute(Z_MT_SD_005_PERFORM_INVOICE);
......
...@@ -12,7 +12,7 @@ public class PriceListServiceTest { ...@@ -12,7 +12,7 @@ public class PriceListServiceTest {
String wsdlLocation = "http://localhost:8080/api/services/price_list?wsdl"; String wsdlLocation = "http://localhost:8080/api/services/price_list?wsdl";
String namespace = "http://price_list.sso.egolm.com"; String namespace = "http://price_list.sso.egolm.com";
String serviceName = "PriceListService"; String serviceName = "PriceListService";
PriceListService service = ServiceFactory.create(PriceListService.class, wsdlLocation, namespace, serviceName, "test", "", "PasswordText"); PriceListService service = ServiceFactory.create(PriceListService.class, wsdlLocation, namespace, serviceName, "test", "");
String XML = StringUtil.readText("D:/data/sso/002.XML"); String XML = StringUtil.readText("D:/data/sso/002.XML");
Z_MT_SD_002_PRICE_LIST Z_MT_SD_002_PRICE_LIST = XMLUtil.toBeanByJxab(XML, Z_MT_SD_002_PRICE_LIST.class); Z_MT_SD_002_PRICE_LIST Z_MT_SD_002_PRICE_LIST = XMLUtil.toBeanByJxab(XML, Z_MT_SD_002_PRICE_LIST.class);
service.execute(Z_MT_SD_002_PRICE_LIST); service.execute(Z_MT_SD_002_PRICE_LIST);
......
...@@ -12,7 +12,7 @@ public class ShippingNotificationTest { ...@@ -12,7 +12,7 @@ public class ShippingNotificationTest {
String wsdlLocation = "http://localhost:8080/api/services/shipping_notification?wsdl"; String wsdlLocation = "http://localhost:8080/api/services/shipping_notification?wsdl";
String namespace = "http://shipping_notfirmation.sso.egolm.com"; String namespace = "http://shipping_notfirmation.sso.egolm.com";
String serviceName = "ShippingNotificationService"; String serviceName = "ShippingNotificationService";
ShippingNotificationService service = ServiceFactory.create(ShippingNotificationService.class, wsdlLocation, namespace, serviceName, "test", "", "PasswordText"); ShippingNotificationService service = ServiceFactory.create(ShippingNotificationService.class, wsdlLocation, namespace, serviceName, "test", "");
String XML = StringUtil.readText("D:/data/sso/007.XML"); String XML = StringUtil.readText("D:/data/sso/007.XML");
Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE = XMLUtil.toBeanByJxab(XML, Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.class); Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE = XMLUtil.toBeanByJxab(XML, Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE.class);
service.execute(Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE); service.execute(Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE);
......
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