我正在调用基于 SOAP 的 API。我需要传递不记名令牌以进行授权。但我不知道如何通过它。
以下是我如何进行API调用
SoapServiceClient cs = new SoapServiceClient (); //initializing SoapHttpClientProtocol
cs.Timeout = 99999999;
cs.Url = "https://gateway.client.com/v1"; //API endpoint
object response = cs.CreateSession(createSessionRequest); //Calling one of its API and assigning the response xml in response object
//how to set bearer token, something like below:
cs.Authorization = "Bearer" + generatedtoken;
我对此不太确定。我按照 this document 在 .net 7 中创建了一个 SOAP Web 服务,然后我可以从邮递员那里获取 API 响应,如下所示。
然后我尝试使用httpClient在.net 7 Web应用程序中调用它。我发现我能够得到回应。然后我注意到在 .net 5+ 中,我们有 corewcf 支持 Http 和 NetTCP 传输。