Initial commit

This commit is contained in:
2020-04-12 20:52:03 -04:00
parent e750d2848a
commit 01e7627293
249 changed files with 9733 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using PartSource.Data.Nexpart;
using System;
using System.Configuration;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace PartSource.Services
{
public class NexpartService
{
public async Task<U> SendRequest<T, U>(T requestContent)
{
Envelope envelope = new Envelope();
envelope.Body.Content = (object)(T)requestContent;
XmlSerializer serializer = new XmlSerializer(typeof(Envelope));
StringBuilder sb = new StringBuilder();
using (TextWriter textWriter = (TextWriter)new StringWriter(sb))
serializer.Serialize(textWriter, (object)envelope);
U content;
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "QUZBNUNDMTQzMUNENDNEQ0E2NjNDMTdCREFEODUwQkItQzhGNUJERjlBMDlDNDQ2NEE2NjczMUNBNDQyN0NCQjk6N0FCMzU3NjYtMDM3OS00REYwLTk2NjUtREFFRTEzODIyRjQz");
try
{
//HttpResponseMessage response = await client.PostAsync(ConfigurationManager.AppSettings["NexpartUrl"], (HttpContent)new StringContent(sb.ToString(), Encoding.UTF8, "text/xml"));
HttpResponseMessage response = await client.PostAsync("http://acespssint.nexpart.com:4001/partselect/1.0/services/PartSelectService.PartSelectHttpSoap11Endpoint/", (HttpContent)new StringContent(sb.ToString(), Encoding.UTF8, "text/xml"));
Stream result = await response.Content.ReadAsStreamAsync();
string str = await response.Content.ReadAsStringAsync();
content = (U)((Envelope)serializer.Deserialize(result)).Body.Content;
}
catch (Exception ex)
{
throw;
}
}
return content;
}
}
}