How to consume WSDL web service

我的未来我决定 提交于 2021-01-28 11:20:33

问题


I need to consume (send request and retrieve the response) of WSDL SAOP web service.

The WSDL document is built with objects of request and response.

How can I call it with XML structure and get as response the XML structure data?

  • I only experienced web service with serializing data and deserializing the data that comes back.

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.


回答1:


I am assuming you are using a c# client to consume a WCF service. 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. Take a look at this http://www.c-sharpcorner.com/UploadFile/0c1bb2/consuming-wcf-service-in-console-application/



来源:https://stackoverflow.com/questions/49011073/how-to-consume-wsdl-web-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!