SOAP UI对接NetSuite沙箱TBA认证失败,请求排查指导
问题:NetSuite令牌认证返回invalidCredentialsFault错误
我正在搭建货运公司与NetSuite的集成,目的是将追踪信息同步至NetSuite。为熟悉流程,我在沙箱账号创建了集成,并用SOAP UI测试。目前getDataCentreUrls函数可以正常运行,但调用getServerTime这类需要认证的函数时,返回invalidCredentialsFault错误。我已经给自己配置了具备令牌认证权限的开发者角色,也生成了令牌,还尝试过token标签对应不同密钥的组合,但都无效。
错误代码
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Server.userException</faultcode> <faultstring>An unexpected error occurred.</faultstring> <detail> <platformFaults:invalidCredentialsFault xmlns:platformFaults="urn:faults_2022_2.platform.webservices.netsuite.com"> <platformFaults:code>UNEXPECTED_ERROR</platformFaults:code> <platformFaults:message>An unexpected error occurred.</platformFaults:message> </platformFaults:invalidCredentialsFault> <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">partners128.prod-cwl-eu6.core.ns.internal</ns1:hostname> </detail> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope>
请求代码
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:messages_2022_2.platform.webservices.netsuite.com" xmlns:urn1="urn:core_2022_2.platform.webservices.netsuite.com"> <soapenv:Header> <urn:tokenPassport> <urn1:account>accountnumber</urn1:account> <urn1:consumerKey>alongconsumerkey</urn1:consumerKey> <urn1:token>alongtoken</urn1:token> </urn:tokenPassport> </soapenv:Header> <soapenv:Body> <urn:getServerTime/> </soapenv:Body> </soapenv:Envelope>
排查方向与解决方法
- 令牌认证请求头缺失关键字段:你的
tokenPassport仅包含account、consumerKey、token,但NetSuite令牌认证需要完整传入5个参数:account、consumerKey、consumerSecret、token、tokenSecret。修正后的请求头示例:<urn:tokenPassport> <urn1:account>你的完整沙箱账号</urn1:account> <urn1:consumerKey>集成的消费者密钥</urn1:consumerKey> <urn1:consumerSecret>集成的消费者密钥密码</urn1:consumerSecret> <urn1:token>生成的令牌</urn1:token> <urn1:tokenSecret>令牌对应的密码</urn1:tokenSecret> </urn:tokenPassport> - 验证账号格式正确性:沙箱账号需使用完整ID,比如带
_SB1这类后缀的账号,不能仅填写主账号数字。 - 核对令牌与角色的绑定关系:生成令牌时必须选择你当前使用的、具备令牌认证权限的开发者角色,确认角色选择无误。
- 检查集成状态与权限:在NetSuite集成管理页面,确认该沙箱集成处于启用状态,且已勾选
Token-Based Authentication权限。 - 确认Web服务端点环境:确保SOAP请求的端点是沙箱环境URL,避免误使用生产环境地址。
内容的提问来源于stack exchange,提问作者TheIronKing
相关产品推荐
相关产品推荐

