5

I am getting the following error when connecting to a NetSuite production account, through the Suitetalk API:

enter image description here

I don't have problems connecting to the Sandbox account for this client. I am connecting through a C# WCF project. I don't believe the problem is with the c# project, since this code is being used in Production with many other clients.

It seems to me like the SOAP message being returned is incorrectly formatted - there seems to be a line break before the 'soapenv' element in the SOAP message. I am getting this error when creating a "get" request against the API(using passport login). This error occurs on any API call though, I did try simply logging in through the API as well.

I have double checked the login details and account information for this client and everything seems in orders. Besides, if this information is incorrect, I should be getting authentication errors - not malformed SOAP messages.

Any help will be appreciated, thanks!

Charl
  • 812
  • 1
  • 8
  • 22
  • It looks like you have an extra carriage return in the namespace declaration. Any chance of a mis-edit somewhere along the way? – bknights Jul 02 '18 at 17:54
  • I don't declare any namespaces. I am using the SuiteTalk WSDL to connect to the API and this error occurs when running a _service.get(recordRef{...}) command. It seems like the SOAP object being returned is incorrect - this is why it looks like a NetSuite problem. – Charl Jul 03 '18 at 09:26
  • File a case with Netsuite. Several times I’ve had errors in one account that don’t show up in another. You might just have to wait but if you file a case they might update your box sooner – bknights Jul 03 '18 at 15:27
  • Thanks. I already filed a case. I always do some research on the side or ask on Stack Overflow while waiting, then it's a race to see who can solve the problem first. I'll post an update when this is solved. – Charl Jul 03 '18 at 17:55
  • 2
    It's a race? With NS support? Do you time that in geologic ages? – bknights Jul 03 '18 at 18:38
  • Haha. Yeah, I'm disappointed, but not surprised to say I'm still waiting. – Charl Jul 04 '18 at 07:52
  • I am running into the same issue, have you gotten an answer yet? – Brian Jul 11 '18 at 18:15
  • @Brian - See my answer below. – Charl Jul 12 '18 at 07:10

3 Answers3

3

It turns out that I needed to use the webservices.na3.netsuite WSDL. I was under the impression that the regular "webservices.netsuite" WSDL would direct any requests to the correct server.

So when connecting to a NetSuite account through SuiteTalk, be sure to make use of the correct WSDL and specify the correct endpoint along with your login credentials. You can check which server your account is hosted on by looking at the URL when logged into your NetSuite account.

Update

I made use of the newest 'DataCenterAwareNetSuiteService' class to dynamically get the correct data center for the current account that I am trying to connect to:

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();
    }
}

The above is called like so:

new DataCenterAwareNetSuiteService("*account number*", false);
Community
  • 1
  • 1
Charl
  • 812
  • 1
  • 8
  • 22
  • Hi @Charl, how did you are creating an invoice for those customer who doesn't have credit limit, i am facing issue, i would appreciate if you can share with me some detail https://stackoverflow.com/questions/52686093/how-to-create-invoice-in-netsuite-using-suitetalk – MUHAMMAD MUBUSHER ASLAM Oct 07 '18 at 06:43
1

With the latest version of NetSuite, some changes have been made to URLs. For instance, now you can have more than one SandBox URL. Because of this, the URL format has changed. The account number used when authenticating is also now different. For sandboxes the account Id is now passed up as ACCOUNTNUMBER_SANDBOXID, for example 12345678_SB1.

You can determine the URLs for the SOAP and REST services by using the datacenterurls endpoint and supplying the account # you would like to determine the URLS for.

https://rest.netsuite.com/rest/datacenterurls?account=YOUR_ACCOUNT_NUMBER

Brian
  • 6,910
  • 8
  • 44
  • 82
  • Thanks. I managed to fix this already. You can look at my edit of my own answer. This seems to be a bit more generic. – Charl Aug 02 '18 at 09:28
1

The functionality below is based on the answer from @Charl above. I have made a couple changes below that provides the same functionality without using inheritance. This may be a simpler implementation for a newer programmer who does not know how to use an inherited class.

    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();
plcnut
  • 43
  • 5
  • thanks for answering. While this is a good answer for a simpler question about how to interact with a service, I think your not exactly speaking to the problems the OP was having. – Jamie Marshall Apr 24 '19 at 22:15
  • @Jamie Marshall I had the exact same problem as the OP which is how I ended up here. His solution posted above is exactly what was needed to fix the problem. I added a new answer because I did not want to use an inherited class in my project. I am not trying to argue, but would like to know what I should do different when answering? Thanks! – plcnut Apr 25 '19 at 12:52