通过Suitetalk API连接到NetSuite生产帐户时出现以下错误:
连接到此客户端的Sandbox帐户时没有问题。我正在通过C#WCF项目进行连接。我不相信问题出在c#项目中,因为此代码在生产中与许多其他客户端一起使用。
在我看来,返回的SOAP消息格式不正确 - 似乎在SOAP消息中的'soapenv'元素之前有一个换行符。我在针对API创建“获取”请求时使用护照登录时收到此错误。但是,任何API调用都会发生此错误,我也尝试过通过API登录。
我已经仔细检查了这个客户端的登录详细信息和帐户信息,所有内容都在订单中。此外,如果此信息不正确,我应该收到身份验证错误 - 而不是格式错误的SOAP消息。
任何帮助将不胜感激,谢谢!
使用最新版本的NetSuite,对URL进行了一些更改。例如,现在您可以拥有多个SandBox URL。因此,URL格式已更改。验证时使用的帐号现在也不同。对于沙箱,帐户ID现在作为ACCOUNTNUMBER_SANDBOXID传递,例如12345678_SB1。
您可以使用datacenterurls
端点并提供您想要确定URLS的帐户来确定SOAP和REST服务的URL。
https://rest.netsuite.com/rest/datacenterurls?account=YOUR_ACCOUNT_NUMBER
事实证明我需要使用webservices.na3.netsuite WSDL。我的印象是,常规的“webservices.netsuite”WSDL会将任何请求定向到正确的服务器。
因此,当通过SuiteTalk连接到NetSuite帐户时,请确保使用正确的WSDL并指定正确的端点以及您的登录凭据。通过在登录NetSuite帐户时查看URL,您可以检查您的帐户所在的服务器。
更新
我利用最新的“DataCenterAwareNetSuiteService”类为我尝试连接的当前帐户动态获取正确的数据中心:
class DataCenterAwareNetSuiteService : NetSuiteService
{
private System.Uri OriginalUri;
public DataCenterAwareNetSuiteService(string account, bool doNotSetUrl)
: base()
{
OriginalUri = new System.Uri(this.Url);
if (account == null || account.Length == 0)
account = "empty";
if (!doNotSetUrl)
{
//var temp = getDataCenterUrls(account);
DataCenterUrls urls = getDataCenterUrls(account).dataCenterUrls;
Uri dataCenterUri = new Uri(urls.webservicesDomain + OriginalUri.PathAndQuery);
this.Url = dataCenterUri.ToString();
}
}
public void SetAccount(string account)
{
if (account == null || account.Length == 0)
account = "empty";
this.Url = OriginalUri.AbsoluteUri;
DataCenterUrls urls = getDataCenterUrls(account).dataCenterUrls;
Uri dataCenterUri = new Uri(urls.webservicesDomain + OriginalUri.PathAndQuery);
this.Url = dataCenterUri.ToString();
}
}
以上称为如下:
new DataCenterAwareNetSuiteService("*account number*", false);
以下功能基于上面@Charl的答案。我在下面进行了一些更改,提供相同的功能而不使用继承。对于不知道如何使用继承类的新程序员来说,这可能是一个更简单的实现。
var accountId = "1234567"; // Insert your account ID here
var Service = new NetSuiteService();
Service.Url = new Uri(Service.getDataCenterUrls(accountId).dataCenterUrls.webservicesDomain + new Uri(Service.Url).PathAndQuery).ToString();