/// <summary> /// Generates the message body. /// </summary> /// <param name="method">The web method.</param> /// <returns>SOAP message body.</returns> private static string GenerateBody(IWebMethod method) { var body = new StringBuilder(); foreach (var parameter in method.Parameters) { body.AppendFormat(PARAMETER_TEMPLATE, parameter.Name, parameter.Value); } return(string.Format(MESSAGE_TEMPLATE, XML_SCHEMA_INSTANCE, XML_SCHEMA, SOAP_SCHEMA, string.Format(BODY_TEMPLATE, method.Name, method.XMLNS, body)) .Replace("\n", "\r\n")); }
public static string SendHttpRequest(IWebService service, IWebMethod method, int port = 80) { var soap = SoapHelper.GenerateSOAP(service, method); return(SendHttpRequest(service.IP, soap.Item1, soap.Item2, port)); }
/// <summary> /// Generates the SOAP message. /// </summary> /// <param name="host">The host address.</param> /// <param name="serviceUrl">The service URL.</param> /// <param name="method">The method.</param> /// <returns><see cref="Tuple"/> with header as a first parameter and SOAP envelop as the second one.</returns> public static Tuple <string, string> GenerateSOAP(string host, string serviceUrl, IWebMethod method) { var body = GenerateBody(method); return(new Tuple <string, string>(GenerateHeader(host, serviceUrl, body.Length), body.Replace("\r\n", "\n"))); }
/// <summary> /// Generates the SOAP message. /// </summary> /// <param name="service">The service.</param> /// <param name="method">The method.</param> /// <returns><see cref="Tuple"/> with header as a first parameter and SOAP envelop as the second one.</returns> public static Tuple <string, string> GenerateSOAP(IWebService service, IWebMethod method) { return(GenerateSOAP(service.IP, service.IP, method)); }