0

我正在尝试从 dotnet 核心 Web API 调用工作日 SOAP 服务,我收到以下错误“HTTP 请求未经授权,客户端身份验证方案‘匿名’。从服务器收到的身份验证标头为‘’。”

这是我试图调用的 SOAP 方法。“https://community.workday.com/sites/default/files/file-hosting/productionapi/Revenue_Management/v34.0/Get_Customer_Portal_Payment_Session.html#Request”

我将 WSDL 文件添加到生成类和所有内容的项目中。这是我尝试过的。不确定这是否是正确的方法

public async Task<Get_Customer_Portal_Payment_SessionOutput> GetInvoicesDetails(string sessionId)
    {
        var binding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
        var endpoint = new EndpointAddress(
            new Uri("SOAP endpoint"),
            new AddressHeader[] { AddressHeader.CreateAddressHeader("Authorization", string.Empty, "Bearer token") });

        var workdayServiceReferenceClient = new Revenue_ManagementPortClient(binding, endpoint);

        //Instantiate Header for the request
        var header = new Workday_Common_HeaderType();
        header.Include_Reference_Descriptors_In_Response = false;
        header.Include_Reference_Descriptors_In_ResponseSpecified = false;

        var request = new Get_Customer_Portal_Payment_Session_RequestType()
        {
            Item = new Customer_Portal_Payment_Session_Request_ReferenceType()
            {
                Customer_Portal_Payment_Session_Reference = new Customer_Portal_Payment_SessionObjectType()
                {
                    ID = new Customer_Portal_Payment_SessionObjectIDType[1]
                    {
                        new Customer_Portal_Payment_SessionObjectIDType()
                        {
                            type = "IID",
                            Value = sessionId,
                        },
                    },
                },
            },
        };

        var data = await workdayServiceReferenceClient.Get_Customer_Portal_Payment_SessionAsync(header, request);

        return data;
    }
4

0 回答 0