using System; using System.Net; using System.Web.Services; using System.Web.Services.Description; using System.Web.Services.Protocols; using System.Windows.Forms; namespace WebserviceTest { [System.ComponentModel.DesignerCategoryAttribute("code")] [WebServiceBinding(Name = "Webserv_Binding", Namespace = "urn:microsoft-dynamics-schemas/codeunit/Webserv")] public class NAV2017ServiceClient : SoapHttpClientProtocol { public NAV2017ServiceClient(string url, string userName, string password, string domain, int timeout) { this.Url = url; this.Timeout = timeout * 1000; if (string.IsNullOrEmpty(userName)) this.UseDefaultCredentials = true; else this.Credentials = (ICredentials)new NetworkCredential(userName, password, domain); } [SoapDocumentMethod("urn:microsoft-dynamics-schemas/codeunit/Webserv:ProcessRequest", ParameterStyle = SoapParameterStyle.Wrapped, RequestNamespace = "urn:microsoft-dynamics-schemas/codeunit/Webserv", ResponseElementName = "ProcessRequest_Result", ResponseNamespace = "urn:microsoft-dynamics-schemas/codeunit/Webserv", Use = SoapBindingUse.Literal)] public void ProcessRequest(string request, ref string response) { //MessageBox.Show(this.Url.ToString()); object[] objArray = this.Invoke("ProcessRequest", new object[2] { (object) request, (object) response }); response = (string)objArray[0]; } protected override WebRequest GetWebRequest(Uri uri) { WebRequest rq = base.GetWebRequest(uri); return rq; } } }
Answers