4

I'm trying to create an integration with NetSuite through its WebService platform (SuiteTalk), but i'm having problems while saving a Customer with a CustomField.

Here's my code:

        StringCustomFieldRef customField = new StringCustomFieldRef();
        customField.setValue("9999999");
        customField.setInternalId("custentity_xx_xxx_xxx");

        CustomFieldRef[] customFields = new CustomFieldRef[1];
        customFields[0] = customField;

        Customer customer = new Customer();
        customer.setSubsidiary(subs);
        customer.setIsPerson(true);
        customer.setFirstName("Joe");
        customer.setLastName("Silver");
        customer.setCustomFieldList(customFields);

        _port.add(customer);

No matter what, it's always the same response:

[Fault Message]: org.xml.sax.SAXException: {urn:core_2016_1.platform.webservices.netsuite.com}CustomFieldRef is an abstract type and cannot be instantiated

I'm doing exactly like in the docs and the samples in the Help Center.

Any thoughts?

Thanks.

blui
  • 71
  • 1
  • 3
  • Shouldn't that be `setCustomFieldList(new CustomFieldList(customFields))`? – Klitos Kyriacou Jun 10 '16 at 08:34
  • 1
    I saw some examples using like this. But I don't know if they changed the wsdl, because the generated class is now receiving an array. `setCustomFieldList(com.netsuite.webservices.platform.core_2016_1.CustomFieldRef[] customFieldList)` – blui Jun 10 '16 at 12:48
  • Im also having the same issue, im porting from php to java and it might be related to this https://bugs.php.net/bug.php?id=39179 – Arqu Jun 30 '16 at 12:27

3 Answers3

1

I use the Python SDK to look it up

custom_field = self.ns_client.SearchStringCustomField(searchValue='China', scriptId="cust_scriptId", operator='contains')
customFieldList = self.ns_client.SearchCustomFieldList(customField)
basic_search = self.ns_client.basic_search_factory('Item',
customFieldList=customFieldList)
paginated_search = PaginatedSearch(client=self.ns_client,
                                           type_name='Item',
                                           basic_search=basic_search,
                                           pageSize=20)
return self._paginated_search_to_generator(paginated_search=paginated_search)

Maybe you can use the data to query

<soap-env:Body>
        <ns0:search
            xmlns:ns0="urn:messages_2019_1.platform.webservices.netsuite.com">
            <ns0:searchRecord
                xmlns:ns4="urn:accounting_2019_1.lists.webservices.netsuite.com"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns4:ItemSearch">
                <ns1:basic
                    xmlns:ns1="urn:accounting_2019_1.lists.webservices.netsuite.com">
                    <ns2:customFieldList
                        xmlns:ns2="urn:common_2019_1.platform.webservices.netsuite.com">
                        <ns3:customField
                            xmlns:ns3="urn:core_2019_1.platform.webservices.netsuite.com"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" scriptId="custitem_origin" operator="contains" xsi:type="ns3:SearchStringCustomField">
                            <ns3:searchValue>China</ns3:searchValue>
                        </ns3:customField>
                    </ns2:customFieldList>
                </ns1:basic>
            </ns0:searchRecord>
        </ns0:search>
    </soap-env:Body>
Connell.O'Donnell
  • 3,603
  • 11
  • 27
  • 61
Alan Shi
  • 11
  • 2
0

The CustomFieldList syntax changed in 2014_1. The ID of a customField must be specified on the scriptId attribute of a <customField/> element instead of the internalId field in your example.

The ruby netsuite bindings handle properly generating the custom field list depending on the API version being used. If you are still having trouble with the Java library, generate the XML with the ruby bindings to easily identify where the Java bindings might be going wrong.

iloveitaly
  • 2,053
  • 22
  • 21
0

After days of fiddling with it, I've found out that Apache Axis has issues with abstract types and there is not much you can do about it unless you can customize how your backend behaves (which is not the case with NS). The issue is that the server doesnt return the implementation class type but the base class type when passing arrays. However you can build your WSDL differently to wrap all the arrays into lists which will then propperly work as per samples. Most notably the -w and -a flags do the magic.

Here is the command I used to build my WSDL:

java -classpath ./axis.jar:commons-logging-1.0.4.jar:commons-discovery-0.2.jar:jaxrpc.jar:wsdl4j-1.5.1.jar:axis-ant.jar:saaj.jar:log4j-1.2.8.jar:activation.jar:javax.mail.jar org.apache.axis.wsdl.WSDL2Java --timeout 180 netsuite.wsdl.xml -a -w -o nswsdlmaster

Also to make life easier make a project out of it include all the dependencies and build a jar from it.

Arqu
  • 419
  • 1
  • 6
  • 18