Prasanna
Prasanna

Reputation: 53

410 Error : Gone while consuming soap services of netsuite in .net core

I am trying to consume the soap web services of netsuite in .net core 2.2. While trying to call a method provided in the reference.cs, the method throws error : : 'The remote server returned an unexpected response: (410) Gone.'

Here's what I have tried :

public async Task<AdarzaService2.getListResponse> Get() 
        {
            AdarzaService2.Passport passport = new Passport();
            AdarzaService2.TokenPassport tokenPassport = new TokenPassport();
            AdarzaService2.ApplicationInfo applicationInfo = new ApplicationInfo();
            AdarzaService2.PartnerInfo partnerInfo = new PartnerInfo();
            AdarzaService2.Preferences preferences = new Preferences();
            AdarzaService2.BaseRef[] baseRef = new BaseRef[1];
            NetSuitePortTypeClient netSuitePortTypeClient = new NetSuitePortTypeClient();
            passport.account = this.configuration["AccountId"];
            passport.email = this.configuration["Email"];
            passport.role = new RecordRef
            {
                name = this.configuration["Role"]
            };
            tokenPassport.account = this.configuration["AccountId"];
            tokenPassport.consumerKey = this.configuration["ConsumerKey"];
            tokenPassport.token = this.configuration["TokenId"];
            applicationInfo.applicationId = this.configuration["ApplicationId"];
            partnerInfo.partnerId = "";
            //baseref[0].name = "";
            var data = await netSuitePortTypeClient.getListAsync(passport, tokenPassport, applicationInfo, partnerInfo, preferences, baseRef);
            return data;
        }

Can anyone tell me what is causing the issue?

Upvotes: 4

Views: 930

Answers (2)

Beeeeee
Beeeeee

Reputation: 144

I know this is an old question, but we just solved this issue, and I'd like to help anyone else running into the 410 error.

  1. Use the generic wsdl address to generate your local Reference.cs file, currently the most recent version lives at https://webservices.netsuite.com/wsdl/v2023_1_0/netsuite.wsdl but check 'NetSuite Versioning and WSDL Versioning Overview' in the NetSuite help to find the most recent version.

  2. If you don't know your service address you will need to make two different NetSuitePortTypeClient services - the first service will do nothing except call the getDataCenterUrlsAsync() method to get the correct webservices urls along with the current port. They are usually in this format: https://{NetSuiteAccountID}.suitetalk.api.netsuite.com/services/{CurrentSoapPort} which results in something like: https://1234567.suitetalk.api.netsuite.com/services/NetSuitePort_2023_1 currently.

  3. Now that you've got the correct webservice address that's specific to your account and port, create another service passing in the NetSuitePortTypeClient.EndpointConfiguration.NetSuitePort enum and your webservice address. Use this secondary service to actually make calls.

  4. If you do know your webservices urls this first service is not necessary, you can create one service using your known webservice address.

I made a little console app to test this all out. I'm not including all the code to build up the tokenPassport, hopefully you've figured that much out but can include in a comment if needed.

var service1 = new NetSuitePortTypeClient();
Console.WriteLine("current endpoint: " + service1.Endpoint.Address);

var results = service1.getDataCenterUrlsAsync(tokenPassport, null, null, null, accountId.ToString()).Result;
var endpointAddress = new EndpointAddress(results.getDataCenterUrlsResult.dataCenterUrls.webservicesDomain + service1.Endpoint.Address.Uri.PathAndQuery);
Console.WriteLine("new endpoint after getting datacenter URLs: " + endpointAddress);

var service2 = new NetSuitePortTypeClient(NetSuitePortTypeClient.EndpointConfiguration.NetSuitePort, endpointAddress); //THIS IS THE SERVICE TO ACTUALLY USE
Console.WriteLine("service2 endpoint: " + service2.Endpoint.Address.Uri);

// Invoke the get() operation to retrieve the record
RecordRef recordRef = new RecordRef();
recordRef.internalId = 33857.ToString(); //BBFC in IM
recordRef.type = RecordType.customer;
recordRef.typeSpecified = true;

var response = await service2.getAsync(tokenPassport, null, null, null, recordRef);

The NetSuite docs are extremely lacking on why this is necessary. See Ben's write up on this issue where he suggested account specific wsdls, and please note Sean's comment - which suggested making a secondary service to get around account specific WSDL urls. https://medium.com/@benwmills/using-the-netsuite-suitetalk-api-with-net-core-net-standard-40f1a4464da1

Upvotes: 1

Bruno Ferreira
Bruno Ferreira

Reputation: 484

I found the answer to this issue. The service requires an endpoint target, that is not specified. You can set the endpoint on the constructor method.

NetSuitePortTypeClient netSuitePortTypeClient = new NetSuitePortTypeClient(NetSuitePortTypeClient.EndpointConfiguration.NetSuitePort, "http://..........");

Upvotes: 2

Related Questions