Capturing SOAP requests to an ASP.NET ASMX web service

You can also implement by placing the code in Global.asax.cs protected void Application_BeginRequest(object sender, EventArgs e) { // Create byte array to hold request bytes byte[] inputStream = new byte[HttpContext.Current.Request.ContentLength]; // Read entire request inputstream HttpContext.Current.Request.InputStream.Read(inputStream, 0, inputStream.Length); //Set stream back to beginning HttpContext.Current.Request.InputStream.Position = 0; //Get XML request string requestString = ASCIIEncoding.ASCII.GetString(inputStream); } I … Read more

Handle exceptions in web services with Elmah

ASP.NET web services never fire Application_Error event and exceptions cannot be handled globally by ELMAH like in ASP.NET apps. But we can “manually” log exceptions using ELMAH: public int WebServiceMethod() { try { … } catch (Exception ex) { Elmah.ErrorLog.GetDefault( HttpContext.Current).Log(new Elmah.Error(ex, HttpContext.Current)); } }

Calling an ASP.NET server side method via jQuery

To call ASP.NET AJAX “ScriptServices” and page methods, you need to use the full $.ajax() syntax: $.ajax({ type: “POST”, url: “MessagePopup.aspx/SendMessage”, data: “{subject:'” + subject + “‘,message:'” + message + “,messageId:'” + messageId + “‘,pupilId:'” + pupilId +”‘}”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function(msg) { // Do something interesting here. } }); See this … Read more

how to generate web service out of wsdl

There isn’t a magic bullet solution for what you’re looking for, unfortunately. Here’s what you can do: create an Interface class using this command in the Visual Studio Command Prompt window: wsdl.exe yourFile.wsdl /l:CS /serverInterface Use VB or CS for your language of choice. This will create a new .cs or .vb file. Create a … Read more

asp.net asmx web service returning xml instead of json

Finally figured it out. The app code is correct as posted. The problem is with the configuration. The correct web.config is: <configuration> <system.web> <compilation debug=”true” targetFramework=”4.0″ /> </system.web> <system.webServer> <handlers> <add name=”ScriptHandlerFactory” verb=”*” path=”*.asmx” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ resourceType=”Unspecified” /> </handlers> </system.webServer> </configuration> According to the docs, registering the handler should be unnecessary from … Read more

What is the difference between an asp.net web method and a wcf service?

ASP.NET Web services was developed for building applications that send and receive messages by using the Simple Object Access Protocol (SOAP) over HTTP. WCF is for enabling .NET Framework applications to exchange messages with other software entities. SOAP is used by default, but the messages can be in any format, and conveyed by using any … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)