Current state, whatever that means

This commit is contained in:
2022-03-17 20:04:12 -04:00
parent fb6dbdfaa7
commit 60edbee0b8
22 changed files with 1087 additions and 156 deletions

View File

@@ -10,34 +10,42 @@ 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;
}
}
public class NexpartService
{
public async Task<U> SendRequest<T, U>(T requestContent)
{
Envelope envelope = new Envelope();
envelope.Body.Content = requestContent;
XmlSerializer serializer = new XmlSerializer(typeof(Envelope));
StringBuilder sb = new StringBuilder();
using (TextWriter textWriter = new StringWriter(sb))
{
serializer.Serialize(textWriter, (object)envelope);
U content;
string x = textWriter.ToString();
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "QjM4ODAyMzM3QjQxNEM2QTk4M0RFMjM0Mjk4Rjk4M0UtOUIzNUUxNzNBQUYxNEE2QjhCQjI2RjZDOUY2ODk1NDU6MkMzOUVCOTYtRDBBRS00QkVBLTlCMzItMUYyNTA5MDJGQTE0");
try
{
//HttpResponseMessage response = await client.PostAsync(ConfigurationManager.AppSettings["NexpartUrl"], (HttpContent)new StringContent(sb.ToString(), Encoding.UTF8, "text/xml"));
HttpResponseMessage response = await client.PostAsync("http://acespssprod.nexpart.com:8081/partselect/1.0/services/PartSelectService.PartSelectHttpSoap11Endpoint/", new StringContent(textWriter.ToString(), Encoding.UTF8));
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;
}
}
}
}