Rahul Patil

Rahul Patil

  • 1.5k
  • 183
  • 31.1k

Issue With WebService in asp.net?

Dec 25 2019 12:30 AM
I m working with web services using store procedure and when I m inserted a record using Webservice then inserted successfully but when I click on service description than data not display but the record is inserted successfully in the database and when  I test my web service in postman then get an error see below:
  1. In PostMan:   
  2. (post) http://localhost:25880/PaymentMode.asmx?op=login   
  1. <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Root element is missing.  
  2. at System.Xml.XmlTextReaderImpl.Throw(Exception e)  
  3. at System.Xml.XmlTextReaderImpl.ParseDocumentContent()  
  4. at System.Xml.XmlTextReaderImpl.Read()  
  5. at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read()  
  6. at System.Xml.XmlReader.MoveToContent()  
  7. at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent()  
  8. at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement()  
  9. at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest()  
  10. at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)  
  11. at System.Web.Services.Protocols.SoapServerProtocol.Initialize()  
  12. at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)  
  13. --- End of inner exception stack trace ---</soap:Text></soap:Reason><soap:Detail /></soap:Fault></soap:Body></soap:Envelope>
  1. [WebMethod]  
  2.     public string login(string uname, string pass)  
  3.     {  
  4.         cn.Open();  
  5.         SqlCommand cmd = new SqlCommand("loginsp", cn);  
  6.         cmd.CommandType = CommandType.StoredProcedure;  
  7.         cmd.Parameters.AddWithValue("@username",uname);  
  8.         cmd.Parameters.AddWithValue("@password", pass);  
  9.         try  
  10.         {  
  11.             cmd.ExecuteNonQuery();  
  12.             return "inserted data successfully";  
  13.   
  14.         }  
  15.         catch (Exception)  
  16.         {  
  17.             return "inserted data not successfully";  
  18.             throw;  
  19.         }  
  20.         finally  
  21.         {  
  22.             cn.Close();  
  23.         }  
  24.     }  
store procedure:
  1. CREATE PROCEDURE loginsp    
  2.     @username varchar(50),    
  3.     @password varchar(50)    
  4. AS    
  5. BEGIN    
  6.     Insert Into studlogin values(@username,@password);    
  7. END    
  8. GO  
problem is that click on service description than data not display but the record is inserted successfully in the database and when I test my web service in postman then get an error??
 
what I m doing wrong in my above code??help??

Answers (9)