Reputation: 79
I have created one web service to save error log
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Configuration;
using System.Data.Common;
using System.Data;
using System.Net.Mail;
using System.IO;
namespace TestErrorHandling
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
public class Service1 : IService1
{
public int SaveErrorLog(CompositeType objCom)
{
int messageId = 0;
try
{
SqlDatabase _errDBConnection = null;
_errDBConnection = new SqlDatabase(ConfigurationManager.ConnectionStrings["ErrorLogConnStr"].ToString());
DbCommand dbCommand = _errDBConnection.GetStoredProcCommand("usp_SaveErrorLog");
_errDBConnection.AddInParameter(dbCommand, "@i_ApplicationId", DbType.Int32, objCom.AppId);
_errDBConnection.AddInParameter(dbCommand, "@i_ExceptionType", DbType.String, objCom.ExceptionType);
_errDBConnection.AddOutParameter(dbCommand, "@O_MESSAGEID", DbType.Int32, 4);
_errDBConnection.ExecuteReader(dbCommand);
messageId = Convert.ToInt32(_errDBConnection.GetParameterValue(dbCommand, "@O_MESSAGEID"));
}
catch (Exception ex)
{
throw new FaultException(ex.Message);
}
return messageId;
}
}
}
Now I am calling this service in my web application
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Collections.Specialized;
using Test.ServiceReference1;
namespace Test
{
public partial class _Default : BasePage
{
ServiceReference1.Service1Client obj1 = new ServiceReference1.Service1Client;
obj1.
}
But after typing obj1. its not showing SaveErrorLog method of Service. Please help on this where I am doing wrong.
added like
Upvotes: 0
Views: 88
Reputation: 110
change
ServiceReference1.Service1Client obj1 = new ServiceReference1.Service1Client;
to
ServiceReference1.Service1Client obj1 = new ServiceReference1.Service1Client();
and then use
obj1.<method name>
also add reference using add service references
like this..
Upvotes: 1