14. Januar 2014 12:49
<?php
$path = realpath("/\\srv-nav\DATA/TEST_11_2013_Data.mdf");
$defaultDir = dirname($path);
$connectionString =
'Driver={Microsoft Navision Driver};'.
'DriverId=790;'.
'Dbq='.$path.';'.
'DefaultDir='.$defaultDir.';';
echo $connectionString;
$conn = mssql_connect($connectionString,"user","passwort") or die("Fehler");
$sql2 = "SELECT * FROM Name";
$result2 = odbc_exec($conn, $sql2);
if (odbc_fetch_row($result2, 1)) {
echo odbc_result($result2, "Name");
}
odbc_close($conn);
?>
14. Januar 2014 14:19
14. Januar 2014 14:21
14. Januar 2014 14:39
14. Januar 2014 15:36
function WriteLog_dbnavsend($errormessage){
$fp=fopen('errorlog.txt','a');
fwrite($fp,$errormessage);
fwrite($fp,"\r\n");
fclose($fp);}
include_once('../includes/configure.php');
require_once(DIR_FS_DOCUMENT_ROOT.'/services/nusoap/lib/nusoap.php'); //$_SERVER['DOCUMENT_ROOT']
WriteLog_dbnavsend(DIR_FS_DOCUMENT_ROOT.'/services/nusoap/lib/nusoap.php');
function NotifyNAV($xtcorderid, $webshopname, $webshopcode){
$navwsurl="ws.domain.de";
$success=0;
if (CheckNAVServerOnline($navwsurl)==1){
$soap = new nusoap_client("http://ws.domain.de/myConnect/GetOrderFromXTC.asmx?WSDL", true);
$params =array('xtcOrderID' => $xtcorderid, 'WebShopName' => $webshopname, 'WebShopSecurityCode' => $webshopcode);
$result = $soap->call("NewOrder", array('parameters' => $params));
WriteLog_dbnavsend("call done");
if(is_array($result)){
foreach($result as $answer){
$success = $answer;
}
}
else {
$success=$result;}
}
return $success;
}
function CheckNAVServerOnline($navwebserver, $navport=80){
$online=0;
$fp = fsockopen($navwebserver, $navport, $errno, $errstr, 3);
if (!$fp) {
WriteLog_dbnavsend("offline");
$online=0;
} else {
$online=1;
WriteLog_dbnavsend("online");
fclose($fp);
}
return $online;
}
14. Januar 2014 15:53
<?php
define('USERPWD', 'intern\expandit:password');
class Webservice {
private $baseURL = 'http://entwicklung.intern.mydomain:7047/DynamicsNAV/WS/';
private $client = null;
public function __construct() {
// we unregister the current HTTP wrapper
stream_wrapper_unregister('http');
// we register the new HTTP wrapper
stream_wrapper_register('http', 'NTLMStream') or die("Failed to register protocol");
}
private function dumpError($faultcode, $faultstring) {
echo "Error:<br />" . nl2br($faultcode) . '<br /><br />Error Details:<br />'. nl2br($faultstring) . '<br />';
echo("<br />REQUESTHEADERS :<br />" . htmlspecialchars($this->client->__getLastRequestHeaders()) . "<br />");
echo("<br />REQUEST :<br />" . htmlspecialchars($this->client->__getLastRequest()) . "<br />");
echo("<br />RESPONSEHEADERS:<br />" .htmlspecialchars($this->client->__getLastResponseHeaders()) . "<br />");
echo("<br />RESPONSE:<br />" .htmlspecialchars($this->client->__getLastResponse()) . "<br />");
}
public function __Action($action, $uri, &$paramsAsArray) {
//var_dump(&$paramsAsArray);
$this->client = @new NTLMSoapClient($this->baseURL.$uri);
try {
$result = $this->client->$action(&$paramsAsArray);
return $result;
} catch (SoapFault $vException) {
$this->dumpError($vException->faultcode,$vException->faultstring);
}
}
public function ListCompanies() {
$this->client = @new NTLMSoapClient($this->baseURL.'SystemService');
try {
// Find the first Company in the Companies
$result = $this->client->Companies();
$companies = $result->return_value;
return $companies;
} catch (SoapFault $vException) {
$this->dumpError($vException->faultcode,$vException->faultstring);
}
}
} //end of class
/* dont touch anything below */
class NTLMSoapClient extends SoapClient {
function __doRequest($request, $location, $action, $version) {
$headers = array(
'Method: POST',
'Connection: Keep-Alive',
'User-Agent: PHP-SOAP-CURL',
'Content-Type: text/xml; charset=utf-8',
'SOAPAction: "'.$action.'"',
);
$this->__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";
}
}
class NTLMStream
{
private $path;
private $mode;
private $options;
private $opened_path;
private $buffer;
private $pos;
/**
* Open the stream
*
* @param unknown_type $path
* @param unknown_type $mode
* @param unknown_type $options
* @param unknown_type $opened_path
* @return unknown
*/
public function stream_open($path, $mode, $options, $opened_path) {
$this->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;
}
}
?>
...
public function __construct($what) {
...
[b] $this->webservice = new Webservice();[/b]
...
$categories = default_Model::getCategories();
$speakers = array();
$speakerObj = $this->webservice->__Action('ReadMultiple', '88%20Aufzugswerke%20M.Schmitt+Sohn/Page/Trainers', $paramsAsArray);
if (is_array($speakerObj->ReadMultiple_Result->Trainers)) {
foreach($speakerObj->ReadMultiple_Result->Trainers as $obj) {
$speakers[] = get_object_vars($obj);
}
} else {
$speakers[] = get_object_vars($courseObj->ReadMultiple_Result->Trainers);
}
if ($this->debug) var_dump($speakers);
14. Januar 2014 16:04
$server = 'ENTWICKLUNG';
// Mit MSSQL verbinden
$verbindung = mssql_connect($server, 'sa', 'passwort');
if (!$verbindung) {
die('Beim Aufbau der Verbindung mit MSSQL ging etwas schief');
}
mssql_select_db('Cronus_60_DE');
$res = mssql_query('SELECT * FROM [dbo].Company');
while ($datensatz = mssql_fetch_array($res)) {
print_r($datensatz);
}
14. Januar 2014 16:26
14. Januar 2014 16:30
14. Januar 2014 16:42
14. Januar 2014 16:54
15. Januar 2014 11:20
<?php
$server = 'srv-nav\navison';
$connectionInfo = array( "Database"=>"TEST_11_2013", "UID"=>"user", "PWD"=>"passwort");
// Mit MSSQL verbinden
$verbindung = sqlsrv_connect($server,$connectionInfo);
if ($verbindung) {
die('Beim Aufbau der Verbindung mit MSSQL ging etwas schief');
}
//mssql_select_db('TEST_11_2013');
$sql ='SELECT * FROM [dbo].Company';
$params = array(1,"somedata");
//$res = sqlsrv_query($verbindung,$sql,$params);
$stmt = sqlsrv_query($sql,$params);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
if( $res === false ) {
die( print_r( sqlsrv_errors(), true));
}
while ($datensatz = sqlsrv_fetch_array($res,SQLSRV_FETCH_ASSOC)) {
print_r($datensatz);
}
?>
15. Januar 2014 12:55
$stmt = sqlsrv_query($sql,$params);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
Ich möchte ja auch ersteinmal nichts schreiben sondern nur etwas auslesen...
16. Januar 2014 08:21
Wenn Du dann mal was nach NAV schreiben willst, fängst Du wieder eine neue Entwicklung an? Du wllst doch hoffentlich nicht direkt in die NAV-DB schreiben
16. Januar 2014 11:11