问题
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