简体   繁体   English

如何使用WSDL Web服务

[英]How to consume WSDL web service

I need to consume (send request and retrieve the response) of WSDL SAOP web service. 我需要使用(发送请求并检索响应)WSDL SAOP Web服务。

The WSDL document is built with objects of request and response. WSDL文档是使用请求和响应的对象构建的。

How can I call it with XML structure and get as response the XML structure data? 如何用XML结构调用它并获得XML结构数据作为响应?

  • I only experienced web service with serializing data and deserializing the data that comes back. 我只有通过序列化数据和反序列化返回的数据才能体验Web服务。

From the docs: 从文档:

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; }     
}

The only examples that I found online, are ones with calling a function in the service, but the service that I need to work with now- don't use functions that I can call to retrieve data. 我在网上找到的唯一示例是在服务中调用函数的示例,但是我现在需要使用的服务-不要使用我可以调用的函数来检索数据。

I am assuming you are using ac# client to consume a WCF service. 我假设您正在使用ac#客户端使用WCF服务。 You need to add service reference to your client project. 您需要向客户项目添加服务引用。 This creates necessary classes from the WSDL and helps you to create request to call web service and get response. 这将从WSDL创建必要的类,并帮助您创建调用Web服务的请求并获得响应。 Take a look at this http://www.c-sharpcorner.com/UploadFile/0c1bb2/consuming-wcf-service-in-console-application/ 看看这个http://www.c-sharpcorner.com/UploadFile/0c1bb2/using-wcf-service-in-console-application/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM