public static XmlDocument CallWebServiceXml(ISoapEnvelope actionEnvelope) { XmlDocument answer = new XmlDocument(); answer.LoadXml(CallWebService(actionEnvelope)); return(answer); }
public static string CallWebService(ISoapEnvelope actionEnvelope) { var url = SERVICE_URL; var action = SERVICE_URL + actionEnvelope.Action; XmlDocument soapEnvelopeXml = actionEnvelope.GenerateEnvelope(); HttpWebRequest webRequest = CreateWebRequest(url, action); InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest); // begin async call to web request. IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null); // suspend this thread until call is complete. You might want to // do something usefull here like update your UI. asyncResult.AsyncWaitHandle.WaitOne(); // get the response from the completed web request. string serverResponse; using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult)) { using (StreamReader rd = new StreamReader(webResponse.GetResponseStream())) { serverResponse = rd.ReadToEnd(); } } return(serverResponse); }
private ISoapEnvelope ProcessSoapRequest(IHttpContext httpContext, XmlNode requestNode) { if (requestRouter == null) { return(new ErrorSoapEnvelope( SoapFaultCode.Server, "Web service is not properly configured")); } ISoapEnvelope response = requestRouter.RouteSoapRequest(httpContext, requestNode); if (response != null) { return(response); } return(new ErrorSoapEnvelope(SoapFaultCode.Client, "Method not supported")); }