/// <summary>
        /// Creates a <see cref="Claim.CheckIn"/> message with a given <paramref name="url"/> claim.
        /// </summary>
        /// <param name="url">
        /// The URL to some payload that will later on be checked out.
        /// </param>
        /// <returns>
        /// The <see cref="Claim.CheckIn"/> message as an <see cref="XmlDocument"/>.
        /// </returns>
        public static XmlDocument CreateCheckIn(string url)
        {
            if (url.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(url));
            }
            var message = MessageBodyFactory.Create <Claim.CheckIn>(
                $"<clm:CheckIn xmlns:clm='{ClaimSchemaTargetNamespace}'>"
                + $"<clm:Url>{url}</clm:Url>"
                + "</clm:CheckIn>");

            return(message);
        }
 public void CreateEnvelopeWithContent()
 {
     Invoking(
         () => MessageBodyFactory.CreateEnvelope <ResendControlEnvelope, soap_envelope_1__1.Fault>(
             "<ns0:ControlMessage xmlns:ns0=\"http://schemas.microsoft.com/BizTalk/2006/reliability-properties\">" +
             "<ns0:Fault xmlns:ns0=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
             "<faultcode>ns0:Server</faultcode>" +
             "<faultstring>Missing or Invalid Information</faultstring>" +
             "<faultactor>clint</faultactor>" +
             "</ns0:Fault>" +
             "</ns0:ControlMessage>"))
     .Should().NotThrow();
 }
Beispiel #3
0
        public static XmlDocument Create(Type schema)
        {
            if (!SchemaMetadata.For(schema).IsEnvelopeSchema)
            {
                throw new ArgumentException(
                          $"Either {schema.FullName} is not an envelope schema or does not derive from {typeof(SchemaBase).FullName}.",
                          nameof(schema));
            }

            var envelope = MessageBodyFactory.Create(schema);
            var xpath    = SchemaMetadata.For(schema).BodyXPath;
            var body     = envelope.SelectSingleNode(xpath);

            if (body == null)
            {
                throw new InvalidOperationException($"Body element cannot be found for envelope schema '{schema.FullName}'.");
            }
            // overwrite the whole body's dummy/default content with the parts' placeholder
            body.InnerXml = $"<ns:parts-here xmlns:ns=\"{SchemaMetadata.For<Batch.Content>().TargetNamespace}\" />";
            return(envelope);
        }
        public void CreatingMessageBodyWithValidContentDoesNotThrow()
        {
            var content = MessageBodyFactory.Create <soap_envelope_1__2.Envelope>().OuterXml;

            Invoking(() => MessageBodyFactory.Create <soap_envelope_1__2.Envelope>(content)).Should().NotThrow();
        }
        public void CreatingMessageBodyWithInvalidContentThrows()
        {
            var content = MessageBodyFactory.Create <soap_envelope_1__1.Envelope>().OuterXml;

            Invoking(() => MessageBodyFactory.Create <soap_envelope_1__2.Envelope>(content)).Should().Throw <XmlSchemaValidationException>();
        }
 public void CreatingMessageBodyForNonSchemaTypeThrows()
 {
     Invoking(() => MessageBodyFactory.Create(typeof(int)))
     .Should().Throw <ArgumentException>().WithMessage("System.Int32 does not derive from Microsoft.XLANGs.BaseTypes.SchemaBase.*");
 }