Reputation: 25
I'm new at C# and i can't understand why i'm getting this error. Here is my code:
public partial class Window : System.Windows.Forms.Form
{
WebServ.ItemDimWs con = new WebServ.ItemDimWs();
decimal length, width, height, weight, rescode;
string user, article, res;
public Window()
{
InitializeComponent();
}
private void Window_Load(object sender, EventArgs e)
{
}
public void btn_send_Click(object sender, EventArgs e)
{
length = Convert.ToDecimal(tb_lenght.Text.ToString());
width = Convert.ToDecimal(tb_width.Text.ToString());
height = Convert.ToDecimal(tb_height.Text.ToString());
weight = Convert.ToDecimal(tb_weight.Text.ToString());
article = tb_article.Text;
user = tb_user.Text;
string result = con.setItemDims(article, length, width, height, weight, weight, "EA", "KG", "CM", user, ref rescode, ref res);
MessageBox.Show(result);
MessageBox.Show("Resp:" + rescode + res + "!!!");
}
}
I need to send some info to the webservice and receive the answer.
Upvotes: 1
Views: 1310
Reputation: 61
Since the webservice method is not returning anything it cannot be called like this.
string result = con.setItemDims(article, length, width, height, weight, weight, "EA", "KG", "CM", user, ref rescode, ref res);
If you want the result to be output you can write service in such a way that result will be out parameter. (If you have access over the web service code.)
Upvotes: 0
Reputation: 1729
WebServ.ItemDimWs.setItemDims does not return anything, so you can't assign the output to a string.
So instead of doing this
string result = con.setItemDims(article, length,
width, height, weight, weight, "EA", "KG", "CM",
user, ref rescode, ref res);
You can go with
con.setItemDims(article, length,
width, height, weight, weight, "EA", "KG", "CM",
user, ref rescode, ref res);
Upvotes: 2
Reputation: 1297
You are assigning a return value of a method setItemDims
to a string variable but the method is void (no return value)
Note: Not sure what are all the parameters of setItemDims
bu I can see you are passing ref res
, this might be a result being set. Again, Just guessing from the naming convention?
Upvotes: 0