private SoapServerMessage Invoke(HttpContext ctx, SoapServerMessage requestMessage) { SoapMethodStubInfo methodInfo = requestMessage.MethodStubInfo; // Assign header values to web service members requestMessage.UpdateHeaderValues(requestMessage.Server, methodInfo.Headers); // Fill an array with the input parameters at the right position object[] parameters = new object[methodInfo.MethodInfo.Parameters.Length]; ParameterInfo[] inParams = methodInfo.MethodInfo.InParameters; for (int n = 0; n < inParams.Length; n++) { parameters [inParams[n].Position] = requestMessage.InParameters [n]; } // Invoke the method try { object[] results = methodInfo.MethodInfo.Invoke(requestMessage.Server, parameters); requestMessage.OutParameters = results; } catch (TargetInvocationException ex) { throw ex.InnerException; } // Check that headers with MustUnderstand flag have been understood foreach (SoapHeader header in requestMessage.Headers) { if (header.MustUnderstand && !header.DidUnderstand) { throw new SoapHeaderException("Header not understood: " + header.GetType(), WebServiceHelper.MustUnderstandFaultCode(requestMessage.IsSoap12)); } } // Collect headers that must be sent to the client requestMessage.CollectHeaders(requestMessage.Server, methodInfo.Headers, SoapHeaderDirection.Out); return(requestMessage); }
private SoapServerMessage Invoke (HttpContext ctx, SoapServerMessage requestMessage) { SoapMethodStubInfo methodInfo = requestMessage.MethodStubInfo; // Assign header values to web service members requestMessage.UpdateHeaderValues (requestMessage.Server, methodInfo.Headers); // Fill an array with the input parameters at the right position object[] parameters = new object[methodInfo.MethodInfo.Parameters.Length]; ParameterInfo[] inParams = methodInfo.MethodInfo.InParameters; for (int n=0; n<inParams.Length; n++) parameters [inParams[n].Position] = requestMessage.InParameters [n]; // Invoke the method try { object[] results = methodInfo.MethodInfo.Invoke (requestMessage.Server, parameters); requestMessage.OutParameters = results; } catch (TargetInvocationException ex) { throw ex.InnerException; } // Check that headers with MustUnderstand flag have been understood foreach (SoapHeader header in requestMessage.Headers) { if (header.MustUnderstand && !header.DidUnderstand) throw new SoapHeaderException ("Header not understood: " + header.GetType(), SoapException.MustUnderstandFaultCode); } // Collect headers that must be sent to the client requestMessage.CollectHeaders (requestMessage.Server, methodInfo.Headers, SoapHeaderDirection.Out); return requestMessage; }