Commit 35f00dac authored by Quxl's avatar Quxl

x

parent 40f9f07a
......@@ -21,7 +21,7 @@ import org.springframework.context.annotation.Configuration;
import com.egolm.sso.services.confirm_quotation.ConfirmQuotationService;
import com.egolm.sso.services.material_master.MaterialMasterService;
import com.egolm.sso.services.preform_invoice.PoformaInvoiceService;
import com.egolm.sso.services.prforma_invoice.PrformaInvoiceService;
import com.egolm.sso.services.price_list.PriceListService;
import com.egolm.sso.services.shipping_notfirmation.ShippingNotificationService;
......@@ -52,7 +52,7 @@ public class WsConfig {
}
@Bean
public Endpoint getProFormaInvoicePoint(PoformaInvoiceService priceListService) {
public Endpoint getProFormaInvoicePoint(PrformaInvoiceService priceListService) {
EndpointImpl endpoint = new EndpointImpl(bus, priceListService);
endpoint.setInInterceptors(Arrays.asList(authInterceptor));
endpoint.publish("/prforma_invoice");
......
......@@ -4,10 +4,12 @@ import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlType(name = "Z_MT_SD_001_MATERIAL_MASTER")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="Z_MT_SD_001_MATERIAL_MASTER", namespace="http://schneider-distributor.com/")
public class Z_MT_SD_001_MATERIAL_MASTER {
RECORD RECORD;
......
package com.egolm.sso.services.preform_invoice;
package com.egolm.sso.services.prforma_invoice;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(targetNamespace = "http://preform_invoice.sso.egolm.com")
public interface PoformaInvoiceService {
@WebService(targetNamespace = "http://prforma_invoice.sso.egolm.com")
public interface PrformaInvoiceService {
@WebMethod
public void execute(Z_MT_SD_005_PERFORM_INVOICE Z_MT_SD_005_PERFORM_INVOICE);
......
package com.egolm.sso.services.preform_invoice;
package com.egolm.sso.services.prforma_invoice;
import java.util.ArrayList;
import java.util.Date;
......@@ -13,28 +13,28 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.egolm.sso.services.CommonService;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_BANK_DATA;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_DOCU_DATE;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_GENERAL_DATA;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_ORGANIZATIONAL_DATA;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_PARTNER_DATA;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_REFERENCE_DATA;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_AMOUNT_DATA;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_DATA;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_MATERIAL_DATA;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_REFERENCE_DATA;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_REFERENCE_PO_TYPE;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_VAT_DATA;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.SUMMARY_GENERAL;
import com.egolm.sso.services.preform_invoice.Z_MT_SD_005_PERFORM_INVOICE.Z_DT_SD_005_PERFORM_INVOICE;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_BANK_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_DOCU_DATE;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_GENERAL_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_ORGANIZATIONAL_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_PARTNER_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_REFERENCE_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_AMOUNT_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_MATERIAL_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_REFERENCE_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_REFERENCE_PO_TYPE;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_VAT_DATA;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.SUMMARY_GENERAL;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE.Z_DT_SD_005_PERFORM_INVOICE;
import com.egolm.sso.util.DateUtil;
import com.egolm.sso.util.SqlUtil;
import com.egolm.sso.util.SqlUtil.Sql;
import com.egolm.sso.util.StringUtil;
@Component
@WebService(serviceName = "PoformaInvoiceService", targetNamespace = "http://preform_invoice.sso.egolm.com", endpointInterface = "com.egolm.sso.services.preform_invoice.PoformaInvoiceService")
public class PoformaInvoiceServiceImpl implements PoformaInvoiceService {
@WebService(serviceName = "PrformaInvoiceService", targetNamespace = "http://prforma_invoice.sso.egolm.com", endpointInterface = "com.egolm.sso.services.prforma_invoice.PrformaInvoiceService")
public class PrformaInvoiceServiceImpl implements PrformaInvoiceService {
@Autowired
JdbcTemplate jdbcTemplate;
......
package test;
package com.egolm.sso.util;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.wss4j.common.ext.WSPasswordCallback;
public class ProFormaInvoiceServiceTest {
public class ServiceFactory {
private static final String username = "test";
private static final String password = "78258c537d6e4d5fb210a57d05619fb6";
public static void main(String[] args) throws Exception {
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
ClientImpl client = (ClientImpl) factory.createClient("http://localhost:8080/sso/services/pro_forma_invoice?wsdl");
public static <T> T create(String wsdlLocation, String namespace, String serviceName, Class<T> requiredType) throws Exception {
Map<String, Object> pro = new HashMap<String, Object>();
pro.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
pro.put(WSHandlerConstants.USER, username);
......@@ -38,25 +33,12 @@ public class ProFormaInvoiceServiceTest {
}
}
});
WSS4JOutInterceptor interceptor = new WSS4JOutInterceptor();
interceptor.setProperties(pro);
client.setOutInterceptors(Arrays.asList(interceptor));
client.invoke("execute", readText("D:/data/sso/005.XML"));
URL WSDL_URL = new URL(wsdlLocation);
QName qName = new QName(namespace, serviceName);
Service dyService = Service.create(WSDL_URL, qName);
T service = dyService.getPort(requiredType);
ClientProxy.getClient(service).getOutInterceptors().add(new WSS4JOutInterceptor(pro));
return service;
}
private static String readText(String path) throws IOException {
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(path)));
String line = null;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line);
}
return sb.toString();
} finally {
br.close();
}
}
}
package com.egolm.sso.util;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import org.dom4j.Document;
......@@ -79,4 +83,18 @@ public class StringUtil {
return format.substring(0, index) + strno;
}
public static String readText(String path) throws IOException {
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(path)));
String line = null;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line);
}
return sb.toString();
} finally {
br.close();
}
}
}
package test;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.wss4j.common.ext.WSPasswordCallback;
import com.alibaba.fastjson.JSON;
import com.egolm.sso.services.material_master.MaterialMasterService;
import com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER;
import com.egolm.sso.util.ServiceFactory;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
public class MaterialMasterServiceTest {
private static final String username = "test";
private static final String password = "78258c537d6e4d5fb210a57d05619fb6";
public static void main(String[] args) throws Exception {
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
ClientImpl client = (ClientImpl) factory.createClient("http://localhost:8080/sso/services/material_master?wsdl");
Map<String, Object> pro = new HashMap<String, Object>();
pro.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
pro.put(WSHandlerConstants.USER, username);
pro.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
pro.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
public void handle(Callback[] callbacks) {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
pc.setPassword(password);
}
}
});
WSS4JOutInterceptor interceptor = new WSS4JOutInterceptor();
interceptor.setProperties(pro);
client.setOutInterceptors(Arrays.asList(interceptor));
client.invoke("execute", readText("D:/data/sso/001.XML"));
String wsdlLocation = "http://localhost:8080/sso/services/material_master?wsdl";
String namespace = "http://material_master.sso.egolm.com";
String serviceName = "MaterialMasterService";
MaterialMasterService service = ServiceFactory.create(wsdlLocation, namespace, serviceName, MaterialMasterService.class);
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);
service.execute(Z_MT_SD_001_MATERIAL_MASTER);
}
private static String readText(String path) throws IOException {
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(path)));
String line = null;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line);
}
return sb.toString();
} finally {
br.close();
}
}
}
package test;
import com.egolm.sso.services.prforma_invoice.PrformaInvoiceService;
import com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE;
import com.egolm.sso.util.ServiceFactory;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
public class PrformaInvoiceServiceTest {
public static void main(String[] args) throws Exception {
String wsdlLocation = "http://localhost:8080/sso/services/prforma_invoice?wsdl";
String namespace = "http://prforma_invoice.sso.egolm.com";
String serviceName = "PrformaInvoiceService";
PrformaInvoiceService service = ServiceFactory.create(wsdlLocation, namespace, serviceName, PrformaInvoiceService.class);
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);
service.execute(Z_MT_SD_005_PERFORM_INVOICE);
}
}
package test;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.wss4j.common.ext.WSPasswordCallback;
import com.alibaba.fastjson.JSON;
import com.egolm.sso.services.material_master.MaterialMasterService;
import com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER;
import com.egolm.sso.util.ServiceFactory;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
public class PriceListServiceTest {
private static final String username = "test";
private static final String password = "78258c537d6e4d5fb210a57d05619fb6";
public static void main(String[] args) throws Exception {
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
ClientImpl client = (ClientImpl) factory.createClient("http://localhost:8080/sso/services/price_list?wsdl");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
properties.put(WSHandlerConstants.USER, username);
properties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
public void handle(Callback[] callbacks) {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
pc.setPassword(password);
}
}
});
WSS4JOutInterceptor interceptor = new WSS4JOutInterceptor();
interceptor.setProperties(properties);
client.setOutInterceptors(Arrays.asList(interceptor));
String xml = readText("D:/data/sso/002.XML");
System.out.println(JSON.toJSONString(client.invoke("execute", xml)));
}
private static String readText(String path) throws IOException {
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(path)));
String line = null;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line);
}
return sb.toString();
} finally {
br.close();
}
String wsdlLocation = "http://localhost:8080/sso/services/price_list?wsdl";
String namespace = "http://price_list.sso.egolm.com";
String serviceName = "PriceListService";
MaterialMasterService service = ServiceFactory.create(wsdlLocation, namespace, serviceName, MaterialMasterService.class);
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);
service.execute(Z_MT_SD_001_MATERIAL_MASTER);
}
}
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