Commit 4d972838 authored by Quxl's avatar Quxl

x

parent 35f00dac
package test;
import com.egolm.sso.services.confirm_quotation.ConfirmQuotationService;
import com.egolm.sso.services.confirm_quotation.Z_MT_SD_008_SO_CONFIRM_QUOTATION;
import com.egolm.sso.util.ServiceFactory;
import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil;
public class ConfirmQuotationTest {
public static void main(String[] args) throws Exception {
String wsdlLocation = "http://localhost:8080/sso/services/confirm_quotation?wsdl";
String namespace = "http://confirm_quotation.sso.egolm.com";
String serviceName = "ConfirmQuotationService";
ConfirmQuotationService service = ServiceFactory.create(wsdlLocation, namespace, serviceName, ConfirmQuotationService.class);
String XML = StringUtil.readText("D:/data/sso/007.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);
service.execute(Z_MT_SD_008_SO_CONFIRM_QUOTATION);
}
}
package test; package test;
import com.egolm.sso.services.material_master.MaterialMasterService; import com.egolm.sso.services.price_list.PriceListService;
import com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER; import com.egolm.sso.services.price_list.Z_MT_SD_002_PRICE_LIST;
import com.egolm.sso.util.ServiceFactory; import com.egolm.sso.util.ServiceFactory;
import com.egolm.sso.util.StringUtil; import com.egolm.sso.util.StringUtil;
import com.egolm.sso.util.XMLUtil; import com.egolm.sso.util.XMLUtil;
...@@ -12,10 +12,10 @@ public class PriceListServiceTest { ...@@ -12,10 +12,10 @@ public class PriceListServiceTest {
String wsdlLocation = "http://localhost:8080/sso/services/price_list?wsdl"; String wsdlLocation = "http://localhost:8080/sso/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";
MaterialMasterService service = ServiceFactory.create(wsdlLocation, namespace, serviceName, MaterialMasterService.class); PriceListService service = ServiceFactory.create(wsdlLocation, namespace, serviceName, PriceListService.class);
String XML = StringUtil.readText("D:/data/sso/001.XML"); String XML = StringUtil.readText("D:/data/sso/002.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_002_PRICE_LIST Z_MT_SD_002_PRICE_LIST = XMLUtil.toBeanByJxab(XML, Z_MT_SD_002_PRICE_LIST.class);
service.execute(Z_MT_SD_001_MATERIAL_MASTER); service.execute(Z_MT_SD_002_PRICE_LIST);
} }
} }
package test; package test;
import java.io.BufferedReader; import com.egolm.sso.services.shipping_notfirmation.ShippingNotificationService;
import java.io.FileInputStream; import com.egolm.sso.services.shipping_notfirmation.Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE;
import java.io.IOException; import com.egolm.sso.util.ServiceFactory;
import java.io.InputStreamReader; import com.egolm.sso.util.StringUtil;
import java.util.Arrays; import com.egolm.sso.util.XMLUtil;
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.util.FileUtil;
public class ShippingNotificationTest { public class ShippingNotificationTest {
private static final String username = "test";
private static final String password = "78258c537d6e4d5fb210a57d05619fb6";
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(); String wsdlLocation = "http://localhost:8080/sso/services/shipping_notification?wsdl";
ClientImpl client = (ClientImpl) factory.createClient("http://localhost:8080/sso/services/shipping_notification?wsdl"); String namespace = "http://shipping_notification.sso.egolm.com";
Map<String, Object> properties = new HashMap<String, Object>(); String serviceName = "ShippingNotificationService";
properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); ShippingNotificationService service = ServiceFactory.create(wsdlLocation, namespace, serviceName, ShippingNotificationService.class);
properties.put(WSHandlerConstants.USER, username); String XML = StringUtil.readText("D:/data/sso/007.XML");
properties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST); 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);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() { service.execute(Z_MT_SD_007_SHIPPING_NOTFIRMATION_FILE);
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));
System.out.println(JSON.toJSONString(client.invoke("execute", FileUtil.readText("D:/data/sso/007.XML"))));
} }
} }
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;
public class SoConfirmQuotationTest {
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/so_confirm_quotation?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/008.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();
}
}
}
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