Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

connecting nav web services from php

Posted on by 109

Hi all,

I am trying to connect the Nav Web Services in Php (followed by this Blog).

but it’s returning an error: SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://localhost:7047/DynamicsNAVPMS/WS/SystemService’ : Start tag expected, ‘<' not found.

my php code is: //ntlmuserid.php

//ntlmstream.php

path = $path;         $this->mode = $mode;         $this->options = $options;         $this->opened_path = $opened_path;         $this->createBuffer($path);         return true;     }     /**      * Close the stream      *      */     public function stream_close() {         curl_close($this->ch);     }     /**      * Read the stream      *      * @param int $count number of bytes to read      * @return content from pos to count      */     public function stream_read($count) {         if(strlen($this->buffer) == 0) {             return false;         }         $read = substr($this->buffer,$this->pos, $count);         $this->pos += $count;         return $read;     }     /**      * write the stream      *      * @param int $count number of bytes to read      * @return content from pos to count      */     public function stream_write($data) {         if(strlen($this->buffer) == 0) {             return false;         }         return true;     }     /**      *      * @return true if eof else false      */     public function stream_eof() {         return ($this->pos > strlen($this->buffer));     }     /**      * @return int the position of the current read pointer      */     public function stream_tell() {         return $this->pos;     }     /**      * Flush stream data      */     public function stream_flush() {         $this->buffer = null;         $this->pos = null;     }     /**      * Stat the file, return only the size of the buffer      *      * @return array stat information      */     public function stream_stat() {         $this->createBuffer($this->path);         $stat = array( ‘size’ => strlen($this->buffer),         );         return $stat;     }     /**      * Stat the url, return only the size of the buffer      *      * @return array stat information      */     public function url_stat($path, $flags) {         $this->createBuffer($path);         $stat = array( ‘size’ => strlen($this->buffer),         );         return $stat;     }     /**      * Create the buffer by requesting the url through cURL      *      * @param unknown_type $path      */     private function createBuffer($path) {         if($this->buffer) {             return;         }         $this->ch = curl_init($path);         curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);         curl_setopt($this->ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);         curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);         curl_setopt($this->ch, CURLOPT_USERPWD, USERPWD);         $this->buffer = curl_exec($this->ch);         $this->pos = 0;     } }

?>

//ntlmsoapclient.php

__last_request_headers = $headers;         $ch = curl_init($location);         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);         curl_setopt($ch, CURLOPT_POST, true );         curl_setopt($ch, CURLOPT_POSTFIELDS, $request);        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);         curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);         curl_setopt($ch, CURLOPT_USERPWD, USERPWD);         $response = curl_exec($ch);         return $response;     }

    function __getLastRequestHeaders() {         return implode(“\n”, $this->__last_request_headers).”\n”;     } }

?>

//client.php

Companies(); $companies = $result->return_value; echo “Companies:”; if (is_array($companies)) {   foreach($companies as $company) {     echo “$company”;   }   $cur = $companies[0]; } else {   echo “$companies”;   $cur = $companies; }

} catch(Exception $ex) {     echo $ex->getMessage(); } ?>

my error is:

SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://localhost:7047/DynamicsNAVPMS/WS/SystemService’ : Start tag expected, ‘<' not found.

Could you tell me where I went wrong?

thanks in advance…….

*This post is locked for comments

  • Suggested answer
    Roberto Stefanetti Profile Picture
    Roberto Stefanetti 12,998 on at
    RE: connecting nav web services from php

    hi,

    might be an authentication problem or string parsering problem

    NAV Web Services are exposed by NAV 2009 or NAV 2013 ?

    If NAV 2009 check:

    > SPN & Trusted delegation for user running NAV Web Service (domain user)  > ceck for ANONYMOUS login attempt in the SQL logs.

    > use NTLM for autentication <add key="WebServicesUseNTLMAuthentication" value="true"></add>

    > select using any protocol to connect and not kerberos only on service tier

    > restart sql & all nav services

    Two links

    blog.artea.info/ms-nav-web-services-tofrom-php-receiving-and-sending-data

    Freddy Blog

    blogs.msdn.com/.../connecting-to-nav-web-services-from-php.aspx

    try to change (suggested by Jega post):  $response = trim(curl_exec($ch))  to remove spaces

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans