如何使用 WSDL 网络服务

How to consume WSDL web service

我需要使用(发送请求和检索响应)WSDL SAOP 网络服务。

WSDL 文档是用请求和响应的对象构建的。

如何使用 XML 结构调用它并获得 XML 结构数据作为响应?

来自文档:

public class GetOrderDetailRequest : Request
{
  public string UserName { get; set; } //Required
  public int SiteID { get; set; }    //Required
  public string Password { get; set; } //Required
  public string OrderID { get; set; }  //Required
}

//    Sample Request XML
//    <GetAdminOrderDetail>
//      <MethodParameters>
//        <req>
//          <OrderID>9063384</OrderID>
//          <Password>test</Password>
//          <SiteID>123</SiteID>
//          <UserName>test</UserName>
//        </req>
//      </MethodParameters>
//    </GetAdminOrderDetail>


// GetOrderDetailResponse object
public class AdminOrderDetail
{
 public List<OrderedColumn> Columns { get; set; }       
 public Invoice Invoice { get; set; }               
 public List<OrderedItem> Items { get; set; }       
 public AdminOrderDetails Details { get; set; }     
}

我在网上找到的唯一示例是在服务中调用函数的示例,但我现在需要使用的服务 - 不要使用我可以调用的函数来检索数据。

我假设您使用 C# 客户端来使用 WCF 服务。您需要将服务引用添加到您的客户项目。这会从 WSDL 创建必要的 类 并帮助您创建请求以调用 Web 服务并获得响应。看看这个http://www.c-sharpcorner.com/UploadFile/0c1bb2/consuming-wcf-service-in-console-application/