You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将同端点多操作的Workday SoapUI API调用迁移至Postman与C#/.NET

解决方案:Workday SOAP API迁移Postman及C#/.NET调用实现

一、解决SoapUI导出Swagger到Postman的「Project is missing REST APIs」错误

Workday收入管理模块的Get_Customers、Get_Customer_Invoices等操作都是SOAP API,而非REST API,SoapUI的「Export Swagger/Open API Definition」功能仅支持REST项目,因此会触发该报错。正确迁移方式是直接导入WSDL到Postman:

  • 打开Postman,点击左上角「Import」
  • 选择「Link」选项,输入Workday收入管理模块的WSDL地址(或上传本地保存的WSDL文件)
  • 导入完成后,Postman会自动生成对应SOAP请求的模板
  • 在请求的「Authorization」标签页选择「Basic Auth」,填入Workday的UserName和Password;若需指定WSS-Password类型(如PasswordDigest),可通过Postman的预请求脚本手动添加WS-Security UsernameToken头

二、C#/.NET中调用Workday SOAP API的实现步骤

1. 生成API代理类

你有两种方式生成Workday API的客户端代理类:

  • Visual Studio图形化操作:右键项目 → 「添加」→「服务引用」,输入WSDL地址,设置命名空间(如Workday.RevenueManagement),点击「确定」自动生成代理类
  • 命令行工具(SvcUtil.exe):执行以下命令生成.cs文件,再添加到项目中:
    SvcUtil.exe https://your-workday-tenant.workday.com/ccx/service/your-tenant/Revenue_Management/v47.0?wsdl /out:WorkdayRevenueClient.cs /namespace:Workday.RevenueManagement
    

2. 配置客户端身份验证与WS-Security

Workday要求使用带WS-Security的用户名密码认证,以下是完整调用示例:

using System.ServiceModel;
using System.ServiceModel.Security;
using Workday.RevenueManagement;

// 自定义绑定配置,适配Workday的SOAP安全要求
var binding = new BasicHttpsBinding(BasicHttpsSecurityMode.TransportWithMessageCredential);
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
binding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Basic256;

// Workday API端点地址(替换为你的租户地址和版本)
var endpoint = new EndpointAddress("https://your-workday-tenant.workday.com/ccx/service/your-tenant/Revenue_Management/v47.0");

using (var client = new RevenueManagementPortClient(binding, endpoint))
{
    // 设置用户名密码
    client.ClientCredentials.UserName.UserName = "your-workday-username";
    client.ClientCredentials.UserName.Password = "your-workday-password";
    // 指定WSS-Password类型(Text或Digest,根据Workday配置选择)
    client.ClientCredentials.UserName.PasswordType = PasswordType.Digest;

    // 构造Get_Customers请求示例
    var request = new Get_CustomersRequestType();
    // 添加查询条件(比如按客户ID查询)
    request.Request_References = new CustomerObjectType[]
    {
        new CustomerObjectType
        {
            ID = new CustomerObjectIDType[] { new CustomerObjectIDType { Value = "CUST-0001" } }
        }
    };

    // 调用API并处理响应
    var response = client.Get_Customers(request);
    foreach (var customer in response.Response_Data.Customer)
    {
        Console.WriteLine($"客户名称:{customer.Name}, 客户ID:{customer.ID[0].Value}");
    }
}

3. 补充说明

  • 确保WSDL版本与Workday租户的API版本一致(示例中为v47.0),避免兼容性问题
  • 若遇到安全协商失败,检查Workday租户是否允许你的客户端IP访问,以及用户名密码的权限是否包含收入管理模块的API调用权限
  • 生产环境中建议将用户名密码存储在配置文件或密钥管理服务中,避免硬编码

内容的提问来源于stack exchange,提问作者Rita

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 11:45:03