Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Get an Epicor Client from WCF
- Required Dll:
- Epicor.ServiceModel
- Erp.Contract.BO.Customer (or whatever BO you need)
- System.ServiceModel
- Usage:
- var wcfBinding = NetTcp.UsernameWindowsChannel();
- EndpointIdentity epid = EndpointIdentity.CreateSpnIdentity("dummy"); //Optional
- var soClient = GetEpicorClient<SalesOrderImpl>(wcfBinding, new Uri(string.Format("net.tcp://{0}/ERP/BO/SalesOrder.svc", Settings.Default.EpicorServer, "user","password")));
- */
- public static ImplBase<T> GetEpicorBOInstance<T>(CustomBinding binding, Uri appServer, string userName, string password, EndpointIdentity epi=null) where T : class
- {
- ImplBase<T> epicorClient = new ImplBase<T>(binding, appServer,epi);
- epicorClient.ClientCredentials.UserName.UserName = userName;
- epicorClient.ClientCredentials.UserName.Password = password;
- return epicorClient;
- }
- //No Cast Needed for this one
- // Usage
- //SalesOrderImpl impl = GetEpicorBOInstance<SalesOrderImpl, SalesOrderSvcContract>(wcfBinding, new Uri(string.Format("net.tcp://{0}/ERP/BO/SalesOrder.svc", Settings.Default.EpicorServer)), Settings.Default.EpicorUser, Settings.Default.EpicorPassword);
- public static TImpl GetEpicorBOInstance<TImpl, TContract>(CustomBinding binding, Uri appServer, string userName, string password, EndpointIdentity epi = null)
- where TImpl : ImplBase<TContract>
- where TContract : class
- {
- TImpl client=(TImpl)Activator.CreateInstance(typeof(TImpl), binding, appServer, epi);
- client.ClientCredentials.UserName.UserName = userName;
- client.ClientCredentials.UserName.Password = password;
- return client;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement