public StringContent CreateFor(SoapAction soapAction, UpnpArgumentList args) { if (soapAction == null) { throw new ArgumentNullException(nameof(soapAction)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } string content = CreateSoapMessage(soapAction, args); return(CreateSoapStringContent(soapAction, content)); }
private static string CreateSoapMessageBody(SoapAction sa, UpnpArgumentList list) { var body = new StringBuilder(); body.Append($"<u:{sa.Action} xmlns:u=\"{sa.ActionNamespace}\">"); foreach (var property in list.Arguments) { string escapedValue = SecurityElement.Escape(property.Value.ToString()); body.Append($"<{property.Name}>{escapedValue}</{property.Name}>"); } body.Append($"</u:{sa.Action}>"); return(body.ToString()); }
private static string CreateSoapMessage(SoapAction sa, UpnpArgumentList list) { var body = CreateSoapMessageBody(sa, list); return($"<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>{body}</s:Body></s:Envelope>"); }