C# wsdl web服务方法多参数

C# wsdl web service method multiple parameters

我在 Visual Studios 2012 中使用了 WSDL Web 服务,它为我提供了一些使用方法。请原谅我,我是这方面的新手。其中一种方法需要3个参数如下:

public string SendMessages(int DeviceID, string DeviceSecret,anamespace.MyService.DeviceMessage[] Messages)
    Member of anamespace.MyService.DeviceInterface

我无法弄清楚如何 insert/use 第三个参数 DeviceMessage[] 恰好是 public class under anamespace.Myservice with several variable types in t as如下:

public class DeviceMessage
    Member of anamespace.Myservice.

与:

public string employeenum {set;get;}
    Member of anamespace.Myservice.DeviceMessage

public int messagenum {set;get;}
    Member of anamespace.Myservice.DeviceMessa

格 等...

我已经尝试在我的 Main() 中这样做:

Myservice.DeviceInterface device_interface = new Myservice.DeviceInterface();
Myservice.DeviceMessage[] device_message = new Myservice.DeviceMessage[0];

string emp_num = device_message[0].employeenum;
emp_num = "123";

等...

string Results;
Results = device_interface.SendMessages(987654,"SomeString",device_message[0])

这就是我卡住的地方。

谢谢!

可能在你的方法中,第三个参数需要 DeviceMessage 数组,而你只传递数组的第一个元素,即 device_message[0].

而不是 device_message[0] 尝试通过 device_message。

尝试:

anamespace.Myservice.DeviceMessage deviceMessage = new anamespace.Myservice.DeviceMessage();
deviceMessage.employeenum = "123";
anamespace.Myservice.DeviceMessage[] device_messages = {deviceMessage};
string Results = device_interface.SendMessages(987654,"SomeString",device_messages);