如何在asp.net Web应用程序中使用Web服务?

时间:2019-10-10 11:25:09

标签: c# asp.net web-services web-applications

我想在我的Web应用程序中使用Web服务。该Web服务已在服务参考中添加,但我似乎无法使用该Web服务的方法。

我已经尝试通过使用“ using ServiceReference1”在顶部调用它,但是使用这些方法的代码给出了错误

using ServiceReference1;

namespace Book_Club
{

    public partial class Registerpage : System.Web.UI.Page
    {
        bool register = true;
        //creating WebServiceSoapClient is also giving errors
        WebServiceSoapClient ws = new WebServiceSoapClient();

        protected void Page_Load(object sender, EventArgs e)
        {
            ServiceReference1.BookClubWebService client = 
                new ServiceReference1.BookClubWebService();

            ValidationSettings.UnobtrusiveValidationMode = 
                UnobtrusiveValidationMode.None;
        }

        protected void RegisterButton_Click(object sender, EventArgs e)
        {
            {
                // Allows the user to register. UserAdd is a method in my webservice    
                register = ws.UserAdd(TextBoxName.Text, SurnameTextBox.Text,
                    EmailTextBox.Text, PasswordTextBox.Text, 
                    ConfirmPasswordTextBox.Text, TextBoxPasswordQuestion.Text, 
                    TextBoxPasswordAnswer.Text);
                if (register == true)
                {
                    LabelRegister.Text = "Registration Done";
                }
                else
                {
                    LabelRegister.Text = "User already exists ";
                }
            }
        }

0 个答案:

没有答案