1
我正在使用RestSharp來請求這是一個簡單的SOAP服務自動化項目。我通過XDocument加載xml,但我不能在request.AddBody
中使用它。Restsharp - 將XDocument轉換爲對象
錯誤:「System.InvalidOperationException」類型的異常出現在RestSharpXML.dll但在用戶代碼中沒有處理
public class SOAPSharp
{
XDocument currencyXML = XDocument.Load(@"../../Data/currencyXML.xml");
[Test]
public void xmlRequest() {
try
{
var client = new RestClient();
var request = new RestRequest("http://www.webservicex.net/periodictable.asmx?WSDL", Method.POST);
request.XmlSerializer = new RestSharp.Serializers.DotNetXmlSerializer();
request.RequestFormat = DataFormat.Xml;
request.AddHeader("Content-Type", "application/xml; charset=utf-8");
// request.AddBody(ParameterType.RequestBody);
request.AddBody(currencyXML);
var response = client.Execute(request);
}
catch (Exception)
{
throw;
}
}
}
謝謝,它的工作原理清楚 –