.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

register web service

Posted By: srinivas     Posted Date: September 27, 2009    Points:2   Category :ASP.Net
how do i register web service written in asp.net 3.5

Responses
Author: Venkat             
Posted Date: September 27, 2009     Points: 5   

Hi Srinivas,

What do you mean by registering a web services? As far as i know you don't need to register web services. you need to just deploy webservices in a we server and the client will invoke by URL of webservices.

Let me know if i misunderstood...

Mark As Answer if this solve your problem
Warm Regards,
Venkat
Author: srinivas             
Posted Date: September 28, 2009     Points: 5   


using System;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class sendmail : System.Web.Services.WebService
{
public string Sending_Email(string strEmailAddrFrom, string[] strEmailAddrTo, int intTotalEmailTo, string strAttachement)
{
EmailAlert NewMail = new EmailAlert();
return NewMail.EmailSent(strEmailAddrFrom,
strEmailAddrTo, intTotalEmailTo, strAttachement);
}

public string EmailSent(string strEmailAddrFrom, string [] strEmailAddrTo, int intTotalEmailTo, string strAttachement)
{
string strSent= " ";
try
{
myMailMessage = new MailMessage();
for (int NumberOfEmails = 0; NumberOfEmails < intTotalEmailTo; NumberOfEmails++)
{
myMailMessage.To.Add(new MailAddress(strEmailAddrTo[NumberOfEmails]));
}
myMailMessage.From = new MailAddress(strEmailAddrFrom, "Admin");
myMailMessage.Subject = "Error On Optimizer Program";
myMailMessage.Body = "Error On Optimizer Program. Please check the detail from the attachment";
myMailMessage.IsBodyHtml = true;
myMailMessage.Priority = MailPriority.High;
if (strAttachement != "" || strAttachement != null)
{
Attachment att = new Attachment(strAttachement);
myMailMessage.Attachments.Add(att);
}
SmtpClient myMailClient = new SmtpClient();
myMailClient.Host = "Your Mail Host";
myMailClient.Port = 25;
myMailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
myMailClient.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
object userState = myMailMessage;
try
{
Console.WriteLine("Mail Sending In progress");
myMailClient.Send(myMailMessage);
}
catch (System.Net.Mail.SmtpException ex)
{
Console.WriteLine(ex.Message, "Send Mail Error");
strSent = strSent + ex.Message;
}
myMailMessage.Dispose();
strSent = "Mail Sent !!";
}
catch (System.Net.Mail.SmtpException exSmtp)
{
Console.WriteLine("Exception occurred:" +
exSmtp.Message, "SMTP Exception Error");
strSent = strSent + "Exception occurred:" + exSmtp.Message;
}
catch (System.Exception exGen)
{
Console.WriteLine("Exception occurred:" +
exGen.Message, "General Exception Error");
strSent = strSent + "Exception occurred:" + exGen.Message;
}
return strSent;
}
}



this is the code for webservice to send email i have written but is not working. can you check for errors in the code and resend me the corrected one.

Author: Venkat             
Posted Date: September 28, 2009     Points: 5   

HI Srinivas,

Just check if your SMTP Mail server require authentication? If yes than pass the SMTP user name and password in
SmtpClient myMailClient = new SmtpClient("UserName","YourPassword");

I suspect that might be the issue...you code is fine.

Mark As Answer if this solve your problem
Warm Regards,
Venkat
Author: Lalij Mer             
Posted Date: January 07, 2010     Points: 5   

Right click your project, add web reference or add service reference. In the dialog box, enter the URL of your service. When you press OK, it should generate a proxy class for you. You can then start using this proxy class.

Please Check my answer if you help....
Thank You...

Lalit.
Author: Lalij Mer             
Posted Date: January 29, 2010     Points: 5   

show this link

http://www.beansoftware.com/ASP.NET-Tutorials/Ajax-Web-Form-Run-Time.aspx

Please Check my answer if you help....
Thank You...

Lalit.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend