我是 C# Soap Web 服务的新手。我可以提出肥皂请求。但不确定如何解析下面的肥皂响应以获取 OrderId 例如。<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <OrderCreateByChannelResponse xmlns="http://retailexpress.com.au/"> <OrderCreateByChannelResult> <Response xmlns=""> <OrderCreate> <Customer> <Result>Success</Result> <ExternalCustomerId>170</ExternalCustomerId> <CustomerId>300941</CustomerId> </Customer> <Order> <Result>Success</Result> <ExternalOrderId>INT_3673_ccv_20190926132240</ExternalOrderId> <OrderId>19-00033544</OrderId> <ChannelID>1</ChannelID> </Order> <OrderItems> <OrderItem> <Result>Success</Result> <ExternalOrderItemId></ExternalOrderItemId> <ProductId>126659</ProductId> <OrderId>19-00033544</OrderId> </OrderItem> </OrderItems>
1 回答
缥缈止盈
TA贡献2041条经验 获得超4个赞
尝试这样
XDocument doc = XDocument.Parse(testXML1);
XNamespace ns = doc.Root.GetDefaultNamespace();
string ExternalCustomerId="";
string CustomerId="";
foreach (XElement element in doc.Descendants(ns + "ExternalCustomerId"))
{
ExternalCustomerId = element.Value;
}
foreach (XElement element in doc.Descendants(ns + "CustomerId"))
{
CustomerId = element.Value;
}
- 1 回答
- 0 关注
- 240 浏览
添加回答
举报
0/150
提交
取消