powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / как задействовать out параметр метода в web-service.
2 сообщений из 2, страница 1 из 1
как задействовать out параметр метода в web-service.
    #32995008
Фотография Axeleron
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Имеется web-service:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;


namespace MaxService
{
	public class InputParams
	{
		public int RagavanID;
		public int ElevanID;
		public int ZaebanID;
	}

	public class OutputParams
	{
		public int ResID;
	}

	public class Max : System.Web.Services.WebService
	{
		[WebMethod]
		public void MyFunction(InputParams Input, out OutputParams Output)
		{
			OutputParams aaa = new OutputParams();
			int ID=Input.RagavanID;
			int EID=Input.ElevanID;
			int ZID=Input.ZaebanID;
			aaa.ResID = ID * EID * ZID;
			Output = aaa;
		}
	}
}

В клиентскоп win-forms пытаюсь вызвать MyFunction:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using aaa.Max;

namespace aaa
{
	public class Form1 : System.Windows.Forms.Form
	{
		private void button1_Click(object sender, System.EventArgs e)
		{
			Max.Max max = new Max.Max();
			InputParams input= new InputParams();
			OutputParams output = new OutputParams();
			
			input.RagavanID =  2 ;
			input.ElevanID =  3 ;
			input.ZaebanID =  4 ;

			max.MyFunction(input, out output);	
		}
	}
}

При компиляции получаем сообщение: No overload for method 'MyFunction' takes '2' arguments. И вправду, IntelliSense показывает что MyFunction принимает лишь один параметр. Как заставить клиент увидеть out-параметр MyFunction? Заранее спасибо!
...
Рейтинг: 0 / 0
как задействовать out параметр метода в web-service.
    #32995011
Фотография Axeleron
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Вопрос снимается :) Вот решение данной проблемы:
web-service:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;


namespace MaxService
{
	public class InputParams
	{
		public int RagavanID;
		public int ElevanID;
		public int ZaebanID;
	}

	public class OutputParams
	{
		public int ResID;
	}

	public class ReturnParams
	{
		public int ReturnID;
	}

	public class Max : System.Web.Services.WebService
	{
		[WebMethod]
		public ReturnParams MyFunction(InputParams Input, out OutputParams Output)
		{
			OutputParams aaa = new OutputParams();
			int ID=Input.RagavanID;
			int EID=Input.ElevanID;
			int ZID=Input.ZaebanID;
			aaa.ResID = ID * EID * ZID;
			Output = aaa;
			ReturnParams returnParams = new ReturnParams();
			returnParams.ReturnID = aaa.ResID;
			return returnParams;
		}
	}
}

клиент:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using aaa.Max;

namespace aaa
{
	public class Form1 : System.Windows.Forms.Form
	{
		private void button1_Click(object sender, System.EventArgs e)
		{
			Max.Max max = new Max.Max();
			InputParams input= new InputParams();
			OutputParams output = new OutputParams();
			ReturnParams ret = new ReturnParams();
			
			input.RagavanID =  2 ;
			input.ElevanID =  3 ;
			input.ZaebanID =  4 ;

			max.MyFunction(input, out output);	
			MessageBox.Show(output.ResID.ToString());
		}
	}
}

форум рулит ;)
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / как задействовать out параметр метода в web-service.
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]