1
我覺得自己像個白癡一樣不得不問這個問題,但我很努力地將Web服務調用中的數字輸出到列表框中。它只是在我的列表框中寫入「Task2.wsCall.Service1SoapClient」。正如我所期望的1,2,3等等,網絡服務只有這個內部它:使用列表框中的c#輸出調用Web服務Windows表單
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public int getNumber(int n)
{
return n * n * 100;
}
}
所以,我可以做到這一點完全錯誤。由於任何人誰幫助了,這裏是我的代碼:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnPress_Click(object sender, EventArgs e)
{
try
{
for (int i = 1; i < 21; i++)
{
wsCall.Service1SoapClient CallWebService = new wsCall.Service1SoapClient();
lstBox.Items.Add(CallWebService);
//lstBox.Items.Add(i);
}
}
catch (Exception)
{
MessageBox.Show("Exception caught.");
}
}
}