C#Engine对象替换Web服务调用

时间:2015-03-26 03:58:48

标签: c# web-services trim

我目前正在开发一个MVC站点,希望能够使用旧的.asmx Web服务。 Web Service的文档提供以下示例:

// Construct a request object
TrimRequest request = new TrimRequest();

// Construct a RecordStringSearchClause, with type
// TitleWord, and argument "reef"
RecordStringSearchClause clause = new RecordStringSearchClause();
clause.Type = RecordStringSearchClauseType.TitleWord;
clause.Arg = "reef";

// Construct a record search, and put our search clause in it
WorkerPortalTest.TRIMWS.RecordSearch search = new WorkerPortalTest.TRIMWS.RecordSearch();
search.Items = new RecordClause[] { clause };

// If we had more than one clause, it would look like:
// search.Items = new RecordClause[] { clause1, clause2, clause3 }
// Put our search operation into our TrimRequest
request.Items = new Operation[] { search };

// Send it off. Whatever comes back will be in response
Engine engine = new Engine();
engine.Credentials = newSystem.Net.NetworkCredential(username, password);
TrimResponse response = engine.Execute(request);

作为一个相当新的C#程序员,除了最后三行之外我完全理解它。我从未见过或使用过Engine object,Visual Studio也不知道它。我查看了MSDN并找到this page,但它说它已被弃用。

我正在寻找正确方向的一些指针来调用Web服务并收回所需的结果。

感谢。

1 个答案:

答案 0 :(得分:0)

Engine是webservice类的一个示例。它在Engine类中调用一个名为“Execute”的方法..