Hi,
I have recently migrated a working asmx webservice to a wcf webservice and the webservice method called when forms have been submitted have stopped working, I don't know if this is due to migrating but could do with some help please, the middle one that returns data from the database works just fine.
The method does call the stored procedure but the values are just default so for instance the sql sent is 'insert into vendor (vendor_name, vendor_area) values(default, default)' and I can't work out where it is coming from, or why this has stopped working now it has been moved to a wcf webservice, before then the values from the form where in the query.
For the dataconnection when you select the element to to submit it says Parameter 'tns:vendorsForm', Type myFields(Complex Type), Element /my:myField.
Please can somebody put me on the right track with this, I am sure I am missing something basic like namespace but not sure what or where.
Many thanks.
Jacqui.
The wcf webservice that has 3 Operation Contracts and a data contract defined in the interface as below.
[OperationContract]
bool UpdateVendor(XmlDocument doc);
[OperationContract]
myFields VendorDetails(int vendor_id);
[OperationContract]
void VendorTableInsert(myFields vendorsForm);
MyFields and ContractFields are defined as DataContracts as below (not complete but enough to show you what I have done).
[DataContract]
public class myFields
{
private string vendorNameField;
private string vendorAreaField;
[DataMember]
public string VendorName {
get {
return this.vendorNameField;
}
set {
this.vendorNameField = value;
}
}
[DataMember]
public string VendorArea {
get {
return this.vendorAreaField;
}
set {
this.vendorAreaField = value;
}
}
}
My webservice method is as below.
public void VendorTableInsert(myFields vendorsForm)
{
string vendorName = vendorsForm.VendorName ;
string vendorArea = vendorsForm.VendorArea ;
using (SqlConnection newConn = new SqlConnection(_connString))
{
using (SqlCommand uCmd = new SqlCommand(sproc_name, newConn))
{
try
{
uCmd.CommandText = sproc_name;
uCmd.CommandType = CommandType.StoredProcedure;
uCmd.Connection.Open();
uCmd.Parameters.AddWithValue("@vendor_name", vendorName);
uCmd.Parameters.AddWithValue("@vendor_area", vendorArea);
int result = uCmd.ExecuteNonQuery();
if (result != 0)
{
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
Trace.WriteLine("Logging Error: " + ex.Message.ToString());
}
finally
{
newConn.Close();
uCmd.Dispose();
TestTracer.Dispose();
}
}
}
}