public ShippingDTO getShippingData(int id) { try { string RequestUrl = String.Format("http://5e209e06e31c6e0014c60962.mockapi.io/api/shipping/{0}", id); ServiceBaseConfig serviceBase = new ServiceBaseConfig(); var responseString = serviceBase.getRequest(RequestUrl); dynamic data = serviceBase.getData(responseString); var shippingData = getMapperForShipping(data); return(shippingData); } catch (Exception ex) { return(null); throw; } }
public T GetService() { ServiceBaseConfig config = this.GetOptionBlock(); EndpointAddress endpointAddress = new EndpointAddress(config.ServiceUrl); Binding binding; HttpClientCredentialType clientType = HttpClientCredentialType.Basic; HttpProxyCredentialType proxyType = HttpProxyCredentialType.Basic; if (config.Transport != null) { Enum.TryParse <HttpClientCredentialType>(config.Transport?.ClientCredentialsType, out clientType); Enum.TryParse <HttpProxyCredentialType>(config.Transport?.ProxyCredentialsType, out proxyType); } switch (config.Binding) { case BindingMode.BasicHttp: BasicHttpSecurityMode basicHttpSecurityMode; if (!Enum.TryParse <BasicHttpSecurityMode>(config.BasicHttpSecurityMode.ToString(), out basicHttpSecurityMode)) { throw new Exception("SecurityMode not found"); } var httpbinding = new BasicHttpBinding(basicHttpSecurityMode); if (config.Transport != null) { httpbinding.Security.Transport.ClientCredentialType = clientType; httpbinding.Security.Transport.ProxyCredentialType = proxyType; } httpbinding.MaxBufferPoolSize = 655369999; httpbinding.MaxBufferSize = 655369999; httpbinding.MaxReceivedMessageSize = 655369999; binding = httpbinding; break; case BindingMode.BasicHttps: BasicHttpsSecurityMode basicHttpsSecurityMode; if (!Enum.TryParse <BasicHttpsSecurityMode>(config.BasicHttpSecurityMode.ToString(), out basicHttpsSecurityMode)) { throw new Exception("SecurityMode not found"); } var httpsbinding = new BasicHttpsBinding(basicHttpsSecurityMode); if (config.Transport != null) { httpsbinding.Security.Transport.ClientCredentialType = clientType; httpsbinding.Security.Transport.ProxyCredentialType = proxyType; } httpsbinding.MaxBufferPoolSize = 655369999; httpsbinding.MaxBufferSize = 655369999; httpsbinding.MaxReceivedMessageSize = 655369999; binding = httpsbinding; break; default: throw new Exception("Binding mode not set"); } var factory = new ChannelFactory <T>(binding, endpointAddress); var serviceProxy = factory.CreateChannel(); return(serviceProxy); }