WSE 3.0 ::: does not contain definition for 'setPolicy'
Hi all,
I'm developing window application and connecting to web service with WSE3.0 using UsernameToken.
everytime i try to debug, i will face one problem;
---------
Error 1 'FinalSenarioProjectPrototype.PropertyCompanywebService.Service' does not contain a definition for 'SetPolicy'
---------
Any body occur this problem before?
thank in advanced (",)
Best Regards,
/////////////////////////////C#.NET window application///////////////////////////
private void btnWebService_Click(object sender, EventArgs e)
{
PropertyCompanywebService.Service srv = new PropertyCompanywebService.Service();
UsernameClientAssertion assert = new UsernameClientAssertion("admin", "nimda");
Policy policy = new Policy();
policy.Assertions.Add(assert);
srv.SetPolicy(policy);<------------------------
bool valid = srv.AddUser(tbName.Text, tbGender.Text, tbSP.Text, tbPassportNo.Text, tbDOE.Text);
if (valid)
lblWSStatus.Text = "sent to company Successfully";
else
lblWSStatus.Text = "Failed to sent to company";
//////////////////////////////web service////////////////////////////////
using System;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Text;
using System.IO;
using System.Web.Security;
using System.Xml;
using Microsoft.Web.Services3;
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[WebService(Namespace = "http://company.com/samples/wse/")]
[Policy("ServerPolicy")] // we define policy on service level, so each service method will be covered by it
public class Service : System.Web.Services.WebService
{
const string connStr = "Data Source=129-22; initial catalog =PropertyCompanyDB; Integrated Security=True";
public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod(Description = "Method to Add User")]
//public bool AddUser(string name, string NRIC, string username, string password, string contact, string address)
public bool AddUser(string name, string gender, string singPassId,string passportNo, string dateOfExpiry)
{
bool returnBool = false;
SqlConnection dbConn = new SqlConnection(connStr);
string sqlStr = "INSERT INTO fwParticulars(name, gender, singPassId, passportNo, dateOfExpiry) values('" + name + "', '" + gender + "', '" + singPassId + "', '" + passportNo + "', '" + dateOfExpiry + "');";
SqlCommand dbCommand = new SqlCommand(sqlStr, dbConn);
try
{
dbConn.Open();
if (dbCommand.ExecuteNonQuery() != 0)
{
returnBool = true;
}
returnBool = true;
}
catch
{
returnBool = false;
}
dbConn.Close();
return returnBool;
}
//trying wse
}