private static async Task <AS4Message> PullResponseWarning() { using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(as4_pullrequest_warning))) { var serializer = new SoapEnvelopeSerializer(); return(await serializer.DeserializeAsync(stream, Constants.ContentTypes.Soap)); } }
private static async Task <AS4Message> GetAS4Message(string soapEnvelopeString) { var serializer = new SoapEnvelopeSerializer(); using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(soapEnvelopeString))) { return(await serializer.DeserializeAsync(stream, "soap/xml")); } }
public async Task Predifined_BizTalk_Sample_Fails_To_Deserialize_Because_Of_Missing_Body() { using (var input = new MemoryStream(Encoding.UTF8.GetBytes(BizTalkUserMessage))) { var sut = new SoapEnvelopeSerializer(); await Assert.ThrowsAsync <ArgumentNullException>( () => sut.DeserializeAsync(input, Constants.ContentTypes.Soap)); } }
private static Task <AS4Message> SerializeDeserializeSoap(AS4Message msg) { var serializer = new SoapEnvelopeSerializer(); var memory = new MemoryStream(); serializer.Serialize(msg, memory); memory.Position = 0; return(serializer.DeserializeAsync(memory, msg.ContentType)); }
protected async Task <MessagingContext> DeserializeSignedMessage(string xml) { var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); var serializer = new SoapEnvelopeSerializer(); const string contentType = "multipart/related; boundary=\"=-dXYE+NJdacou7AbmYZgUPw==\"; type=\"application/soap+xml\"; charset=\"utf-8\""; AS4Message as4Message = await serializer.DeserializeAsync(memoryStream, contentType); return(new MessagingContext(as4Message, MessagingContextMode.Unknown)); }
public async Task DeserializeSoapEnvelopeWithoutMessagingHeaderThrowsInvalidMessageException() { const string xmlContent = @"<?xml version=""1.0""?><s12:Envelope xmlns:s12 = ""http://www.w3.org/2003/05/soap-envelope""><s12:Header/></s12:Envelope>"; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xmlContent))) { await Assert.ThrowsAsync <InvalidMessageException>( async() => { var s = new SoapEnvelopeSerializer(); await s.DeserializeAsync(stream, "application/xml"); }); } }
public async Task Then_MessageUnits_Appear_In_The_Same_Order_As_Serialized() { var serializer = new SoapEnvelopeSerializer(); using (var str = new MemoryStream( Encoding.UTF8.GetBytes( Properties.Resources.as4_soap_user_receipt_message))) { AS4Message actual = await serializer .DeserializeAsync(str, Constants.ContentTypes.Soap); Assert.IsType <Receipt>(actual.MessageUnits.First()); Assert.IsType <UserMessage>(actual.MessageUnits.ElementAt(1)); Assert.IsType <Receipt>(actual.MessageUnits.Last()); Assert.Equal( Enumerable.Range(1, 3), actual.MessageUnits.Select(m => int.Parse(m.MessageId))); } }