【问题标题】:Consume a QAAWS with Visual Studio 2010使用 Visual Studio 2010 使用 QAAWS
【发布时间】:2015-09-09 20:58:39
【问题描述】:

我得到了一个 QAAWS,我需要从中提取数据。对于隐私问题,我不能给你 QAAWS,但它和this 一样。

我将 wsdl 添加为服务参考,但我不确定如何获取数据,因为我必须输入登录名和密码。我可以使用 SOAPUI 并获得一个我可以使用的 XML 文件,但我希望在我将 QAAWS 与我的网站一起使用时使该过程更加自动化。

我没有找到任何好的教程或指南。有没有人处理过这些服务?

【问题讨论】:

    标签: asp.net web-services visual-studio-2010 wsdl


    【解决方案1】:

    您可以执行以下操作:

    1. 在 Visual Studio 10 中创建一个新的控制台应用程序
    2. 接下来添加一个 Web 引用并使用提供给您的 Web 服务 WSDL URL。
    3. 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();
                  }
              }
          }
      

    如果您愿意,可以将usernamepassword 写入代码中。这最初来自这个page。我用我自己的 Web 服务对其进行了测试,它确实有效。

    【讨论】:

      猜你喜欢
      • 2012-04-14
      • 1970-01-01
      • 2015-01-04
      • 2011-07-12
      • 1970-01-01
      • 2011-04-08
      • 2013-05-11
      • 2011-10-23
      • 2012-01-25
      相关资源
      最近更新 更多