使用 Visual Studio 2010 年的 QAAWS
Consume a QAAWS with Visual Studio 2010
我获得了 QAAWS,我需要从中提取数据。对于隐私问题,我不能给你 QAAWS,但它与 this 相同。
我添加了 wsdl 作为服务参考,但我不确定如何获取数据,因为我必须输入登录名和密码。我可以使用 SOAPUI 并获得一个我可以使用的 XML 文件,但我想在我的网站上使用 QAAWS 时使过程更加自动化。
我没有找到任何好的教程或指南。有人以前处理过这些服务吗?
您可以执行以下操作:
- 在Visual Studio10创建一个新的控制台应用程序
- 接下来添加 Web 引用并使用提供给您的 Web 服务 WSDL URL。
在 program.cs
文件中写入以下代码(TestWeb
这里是您的 Web 引用的名称。):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using
ConsoleApplication1.TestWeb;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ConsoleApplication1.TestWeb.TestService test1 = new
ConsoleApplication1.TestWeb.TestService();
String message, creatorname, creationdateformatted, description, universe;
DateTime creationdate;
int queryruntime, fetchedrows;
ConsoleApplication1.TestWeb.Row[] row = test1.runQueryAsAService("<cms username>", "<password>", out message, out creatorname, out creationdate, out creationdateformatted, out description, out universe, out queryruntime , out fetchedrows);
int resultCount = row.Length;
Console.WriteLine("Message = " + message);
Console.WriteLine("Creator Name = " + creatorname);
Console.WriteLine("Creation Date = " + creationdate.ToString());
Console.WriteLine("Creation Date Formatted = " + creationdateformatted);
Console.WriteLine("Description = " + description);
Console.WriteLine("Universe = " + universe);
Console.WriteLine("Query Run Time = " + queryruntime);
Console.WriteLine("Fetched Rows = " + fetchedrows);
for (int i = 0; i < resultCount; i++)
{
Console.WriteLine(row[i].ShipperID + " " + row[i].CompanyName + " " + row[i].Phone);
}
Console.Read();
}
}
}
username
和password
可以自己写代码。原文出自此page。我针对我自己的 Web 服务对其进行了测试并且它有效。
我获得了 QAAWS,我需要从中提取数据。对于隐私问题,我不能给你 QAAWS,但它与 this 相同。
我添加了 wsdl 作为服务参考,但我不确定如何获取数据,因为我必须输入登录名和密码。我可以使用 SOAPUI 并获得一个我可以使用的 XML 文件,但我想在我的网站上使用 QAAWS 时使过程更加自动化。
我没有找到任何好的教程或指南。有人以前处理过这些服务吗?
您可以执行以下操作:
- 在Visual Studio10创建一个新的控制台应用程序
- 接下来添加 Web 引用并使用提供给您的 Web 服务 WSDL URL。
在
program.cs
文件中写入以下代码(TestWeb
这里是您的 Web 引用的名称。):using System; using System.Collections.Generic; using System.Linq; using System.Text; using ConsoleApplication1.TestWeb; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { ConsoleApplication1.TestWeb.TestService test1 = new ConsoleApplication1.TestWeb.TestService(); String message, creatorname, creationdateformatted, description, universe; DateTime creationdate; int queryruntime, fetchedrows; ConsoleApplication1.TestWeb.Row[] row = test1.runQueryAsAService("<cms username>", "<password>", out message, out creatorname, out creationdate, out creationdateformatted, out description, out universe, out queryruntime , out fetchedrows); int resultCount = row.Length; Console.WriteLine("Message = " + message); Console.WriteLine("Creator Name = " + creatorname); Console.WriteLine("Creation Date = " + creationdate.ToString()); Console.WriteLine("Creation Date Formatted = " + creationdateformatted); Console.WriteLine("Description = " + description); Console.WriteLine("Universe = " + universe); Console.WriteLine("Query Run Time = " + queryruntime); Console.WriteLine("Fetched Rows = " + fetchedrows); for (int i = 0; i < resultCount; i++) { Console.WriteLine(row[i].ShipperID + " " + row[i].CompanyName + " " + row[i].Phone); } Console.Read(); } } }
username
和password
可以自己写代码。原文出自此page。我针对我自己的 Web 服务对其进行了测试并且它有效。