【发布时间】:2021-11-02 09:06:20
【问题描述】:
我尝试使用 RestClient 从 soapenv 获取会话 ID,但我得到的值为 0 或 -1。
这是我的代码
var client = new RestClient(url);
client.Authenticator = new HttpBasicAuthenticator(name, pwd);
var request = new RestRequest("/{sessionID}",Method.GET);
var response = client.Get(request);
var content = response.Content; // Raw content as string
Console.WriteLine(response.ContentLength);
我的 Soapenv 看起来像这样
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v7="urn://oracle.bi.webservices/v7">
<soapenv:Header/>
<soapenv:Body>
<v7:logon>
<v7:name>pxxxx</v7:name>
<v7:password>Pxxxx</v7:password>
</v7:logon>
</soapenv:Body>
</soapenv:Envelope>
我正在尝试获取看起来像这样的会话 ID (9insv92nke9lig83bqd5pu5tqt7kp8u0toe9l)
<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" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:sawsoap="urn://oracle.bi.webservices/v7">
<soap:Body>
<sawsoap:logonResult>
<sawsoap:sessionID xsi:type="xsd:string">9insv92nke9lig83bqd5pu5tqt7kp8u0toe9l</sawsoap:sessionID>
</sawsoap:logonResult>
</soap:Body>
</soap:Envelope>
无法弄清楚如何获取会话 ID。有人可以帮忙吗?
【问题讨论】:
-
您的偏好是什么。您可以使用 XmlDocument 或 XDocument 或 XmlSerialization 或 Create a Controller 进行解析。
-
无偏好。无论哪种方式都有效。
标签: c# xml rest-client soapexception