1

we are currently trying to integrate into the Netsuite webservice, however we do not wish to use their PHP connector kit. we have already got a script we have developed using Coldfusion and cfhttp to post data into Netsuite without any issue.

Right now we currently have the scripts converted into PHP and are using the curl function to send data to Netsuite.

We can successfully create a new sales order record without any issue, however obtaining the return response message is proving to quite difficult as all we are getting is 302 redirects.

Im assuming that this may have something to do with login credentials for performing the collecting of the return object, however I have no idea on how to store this data in a cookie value so it can continue to be read across the system to system integration.

Below is our CURL code

$http_header = array(
    'Content-Type: text/xml; charset="utf-8"',
    'SOAPAction: getItemAvailability',
    'Content-Length: ' . strlen($myXml),
    'Accept: text/xml',
    'Cache-Control: no-cache',
    'Pragma: no-cache'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->wdsl);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $myXml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$returnObj = curl_exec($ch);
curl_close($ch);

we have tried various things but cannot seem to get it to work so we can obtain the return xml data, its creating the records with no issue what so ever.. Any suggestions would be greatly appreciated

hakre
  • 193,403
  • 52
  • 435
  • 836
user964202
  • 73
  • 7
  • Please see [Php - Debugging Curl](http://stackoverflow.com/questions/3757071/php-debugging-curl). You also might want to use the `CURLOPT_FOLLOWLOCATION` option, see [Make curl follow redirects?](http://stackoverflow.com/q/3519939/367456) – hakre Mar 13 '13 at 09:15
  • Have you included the credentials in each request XML? Also consider this http://dreamxtream.wordpress.com/2012/11/23/new-data-centers-for-netsuite-accounts/ – Saqib Feb 27 '13 at 10:04
  • Could you post the full HTTP response you are getting? – iloveitaly Oct 09 '15 at 12:55

1 Answers1

0

I would recommend using a wrapper library instead of curl for NetSuite communication. I've done a lot of work with the ruby wrapper and it's worked great for me.

One of the reasons you can get a 302 is that account you are trying to access is in a different datacenter than the current WSDL you are pointing to. The standard WSDL domain is system.netsuite.com but many NetSuite installations are on system.na1.netsuite.com. The easiest way to check which datacenter you are on is to login to the GUI and look at the domain.

iloveitaly
  • 2,053
  • 22
  • 21