//private void ParseHeaders(IHeaderDictionary headers) //{ // StringValues soapActions; // string soapAction = string.Empty; // // parse soap action in header of this request // if (headers.TryGetValue("SOAPAction", out soapActions)) // { // soapAction = soapActions.First().ToString(); // _skeletonSoapAction = MatchingSkeleton(ExploreSoapActionFrom(soapAction)); // } //} private void ParseBody(Stream body) { string rawBody = null; using (var reader = new StreamReader(body)) { rawBody = reader.ReadToEnd(); } if (!string.IsNullOrEmpty(rawBody)) { var xmlBody = new XmlDocument(); xmlBody.LoadXml(rawBody); var soapBodyContent = xmlBody.GetElementsByTagName("soap:Body").Item(0).FirstChild; _skeletonAction = MatchingSkeleton(soapBodyContent.Name); if (soapBodyContent.HasChildNodes) { foreach (XmlNode node in soapBodyContent.ChildNodes) { _requestParams.Add(node.Name.Trim(), node.InnerText.Trim()); } } } }
public WCRequestBridge(HttpRequest request) { _requestParams = new Dictionary <string, string>(); _skeletonAction = WCSkeletonWebMethod.None; //ParseHeaders(request.Headers); ParseBody(request.Body); }
public WCResponseBridge(WCSkeletonWebMethod skeletonMethod, dynamic result) { Envelope = new XElement(soap + "Envelope", new XAttribute(XNamespace.Xmlns + "soap", soap.NamespaceName), new XAttribute(XNamespace.Xmlns + "xsi", xsi.NamespaceName), new XAttribute(XNamespace.Xmlns + "xsd", xsd.NamespaceName) ); Body = new XElement(soap + "Body"); switch (skeletonMethod) { case WCSkeletonWebMethod.ServerVersion: Response = new XElement(qb + WC_RESPONSE.SERVER_VERSION); Result = new XElement(qb + WC_RESPONSE_RESULT.SERVER_VERSION, result); break; case WCSkeletonWebMethod.ClientVersion: Response = new XElement(qb + WC_RESPONSE.CLIENT_VERSION); Result = new XElement(qb + WC_RESPONSE_RESULT.CLIENT_VERSION, result); break; case WCSkeletonWebMethod.Authenticate: Response = new XElement(qb + WC_RESPONSE.AUTHENTICATE); Result = new XElement( qb + WC_RESPONSE_RESULT.AUTHENTICATE, new XElement(qb + "string", result[0]), new XElement(qb + "string", result[1]) ); break; case WCSkeletonWebMethod.SendRequestXML: Response = new XElement(qb + WC_RESPONSE.SEND_REQUEST_XML); Result = new XElement(qb + WC_RESPONSE_RESULT.SEND_REQUEST_XML, result); break; case WCSkeletonWebMethod.ReceiveResponseXML: Response = new XElement(qb + WC_RESPONSE.RECEIVE_RESPONSE_XML); Result = new XElement(qb + WC_RESPONSE_RESULT.RECEIVE_RESPONSE_XML, result); break; case WCSkeletonWebMethod.ConnectionError: Response = new XElement(qb + WC_RESPONSE.CONNECTION_ERROR); Result = new XElement(qb + WC_RESPONSE_RESULT.CONNECTION_ERROR, result); break; case WCSkeletonWebMethod.GetLastError: Response = new XElement(qb + WC_RESPONSE.GET_LAST_ERROR); Result = new XElement(qb + WC_RESPONSE_RESULT.GET_LAST_ERROR, result); break; case WCSkeletonWebMethod.CloseConnection: Response = new XElement(qb + WC_RESPONSE.CLOSE_CONNECTION); Result = new XElement(qb + WC_RESPONSE_RESULT.CLOSE_CONNECTION, result); break; default: break; } Response.Add(Result); Body.Add(Response); Envelope.Add(Body); }