Hello,
I have an integration on my website with Microsoft Dynamics NAV (2016) to Create, Read, Update, Delete data. Website is based on Wordpress therefore I am using PHP to send the requests but having some troubles to even read the data. Here is one of my code examples (as I tried many):
<?php
$soapUrl = "http://{IP}:{PORT}/TEST/WS/{CompanyName}/Page/PolicyList";
$xml_post_string = '<Envelope xmlns="schemas.xmlsoap.org/.../envelope">
<Body>
<Read xmlns="urn:microsoft-dynamics-schemas/page/policylist">
<Policy_No>P0000</Policy_No>
</Read>
</Body>
</Envelope>';
$action = "urn:microsoft-dynamics-schemas/page/policylist:Read";
$ipAddress = "{SERVER IP}";
$headers = array(
'Method: POST',
'Accept: text/xml',
'Host: {IP}:{PORT}',
'Connection: Keep-Alive',
'Cache-Control: private',
'Pragma: no-cache',
'User-Agent: PHP-SOAP-CURL',
'Content-Type: text/xml; charset=utf-8',
'SOAPAction: urn:microsoft-dynamics-schemas/page/policylist:Read',
'Content-length: '.strlen($xml_post_string),
);
$url = $soapUrl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "{username}:{password}");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_INTERFACE, $ipAddress);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
if(curl_exec($ch) === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
echo 'Operation completed!';
}
curl_close($ch);
?>
I always get "Curl error: Failed to connect to {IP} port {PORT}: Connection timed out" error.
I could load services only via Chrome extension called "Wizdler". I can send and receive back the data very easily. But can't reach that via PHP.
Does anyone know what I am doing wrong pls? Appreciate your help.
Thanks
*This post is locked for comments
I have the same question (0)