├── AddOrderSAP_example.php ├── DiServerServices.php ├── README.md └── xmlorder_var.php /AddOrderSAP_example.php: -------------------------------------------------------------------------------- 1 | DataBaseServer=""; 40 | $login->DataBaseName=""; 41 | $login->DataBaseType=""; 42 | $login->DataBaseUserName=""; // string 43 | $login->DataBasePassword=""; // string 44 | $login->CompanyUserName=""; // string 45 | $login->CompanyPassword=""; // string 46 | $login->Language="23"; // string 47 | $login->LicenseServer="HOST:30000"; // Change HOST and port 48 | 49 | 50 | // Call to Login Service with the $login Object 51 | $IdSession=$service->Login($login)->LoginResult; 52 | 53 | // Check Here if $IdSession is OK. Otherwise, it had a problem 54 | // with login credentials 55 | 56 | 57 | // /*To see the login LOG:*/ var_dump($IdSession); 58 | 59 | 60 | // Create a new SAP Order 61 | $addOrder= new AddOrder(); 62 | // Order require Valid IDSession 63 | $addOrder->SessionID=$IdSession; 64 | 65 | // xmlOrderComposed is defined in another file: xmlorder_var.php 66 | // You can paste the code inside xmlorder_var.php here 67 | 68 | $addOrder->sXmlOrderObject=$xmlOrderComposed; 69 | 70 | $result=$service->AddOrder($addOrder); 71 | 72 | // In result->AddOrderResult->any and AddOrderResult 73 | // you have the XML SOAP code with the result of the order (ID, etc.) 74 | 75 | //echo $result->AddOrderResult->any; 76 | 77 | 78 | ?> -------------------------------------------------------------------------------- /DiServerServices.php: -------------------------------------------------------------------------------- 1 | 62 | } 63 | 64 | class GetEmptyOrderXml { 65 | public $sSessionID; // string 66 | } 67 | 68 | class GetEmptyOrderXmlResponse { 69 | public $GetEmptyOrderXmlResult; // GetEmptyOrderXmlResult 70 | } 71 | 72 | class GetEmptyOrderXmlResult { 73 | public $any; // 74 | } 75 | 76 | class GetRecordsetXml { 77 | public $sSessionID; // string 78 | public $sSQL; // string 79 | } 80 | 81 | class GetRecordsetXmlResponse { 82 | public $GetRecordsetXmlResult; // GetRecordsetXmlResult 83 | } 84 | 85 | class GetRecordsetXmlResult { 86 | public $any; // 87 | } 88 | 89 | class AddQuotation { 90 | public $SessionID; // string 91 | public $sXmlQuotationObject; // string 92 | } 93 | 94 | class AddQuotationResponse { 95 | public $AddQuotationResult; // AddQuotationResult 96 | } 97 | 98 | class AddQuotationResult { 99 | public $any; // 100 | } 101 | 102 | class AddOrder { 103 | public $SessionID; // string 104 | public $sXmlOrderObject; // string 105 | } 106 | 107 | class AddOrderResponse { 108 | public $AddOrderResult; // AddOrderResult 109 | } 110 | 111 | class AddOrderResult { 112 | public $any; // 113 | } 114 | 115 | class UpdateQuotation { 116 | public $sSessionID; // string 117 | public $sXmlQuotationObject; // string 118 | } 119 | 120 | class UpdateQuotationResponse { 121 | public $UpdateQuotationResult; // UpdateQuotationResult 122 | } 123 | 124 | class UpdateQuotationResult { 125 | public $any; // 126 | } 127 | 128 | class AddOrder_DI { 129 | public $sSessionID; // string 130 | public $dsOrder; // dsOrder 131 | } 132 | 133 | class dsOrder { 134 | public $schema; // 135 | public $any; // 136 | } 137 | 138 | class AddOrder_DIResponse { 139 | public $AddOrder_DIResult; // AddOrder_DIResult 140 | } 141 | 142 | class AddOrder_DIResult { 143 | public $schema; // 144 | public $any; // 145 | } 146 | 147 | class ConsultaCliente { 148 | public $sSessionID; // string 149 | public $sCliente; // string 150 | } 151 | 152 | class ConsultaClienteResponse { 153 | public $ConsultaClienteResult; // ConsultaClienteResult 154 | } 155 | 156 | class ConsultaClienteResult { 157 | public $schema; // 158 | public $any; // 159 | } 160 | 161 | 162 | /** 163 | * DiServerServicesSample class 164 | * 165 | * 166 | * 167 | * @author Manuel Parra 168 | * @copyright 2013 169 | * @package DiServerBO 170 | */ 171 | class DiServerServicesSample extends SoapClient { 172 | 173 | private static $classmap = array( 174 | 'Login' => 'Login', 175 | 'LoginResponse' => 'LoginResponse', 176 | 'LogOut' => 'LogOut', 177 | 'LogOutResponse' => 'LogOutResponse', 178 | 'GetEmptyQuotationXml' => 'GetEmptyQuotationXml', 179 | 'GetEmptyQuotationXmlResponse' => 'GetEmptyQuotationXmlResponse', 180 | 'GetEmptyQuotationXmlResult' => 'GetEmptyQuotationXmlResult', 181 | 'GetEmptyOrderXml' => 'GetEmptyOrderXml', 182 | 'GetEmptyOrderXmlResponse' => 'GetEmptyOrderXmlResponse', 183 | 'GetEmptyOrderXmlResult' => 'GetEmptyOrderXmlResult', 184 | 'GetRecordsetXml' => 'GetRecordsetXml', 185 | 'GetRecordsetXmlResponse' => 'GetRecordsetXmlResponse', 186 | 'GetRecordsetXmlResult' => 'GetRecordsetXmlResult', 187 | 'AddQuotation' => 'AddQuotation', 188 | 'AddQuotationResponse' => 'AddQuotationResponse', 189 | 'AddQuotationResult' => 'AddQuotationResult', 190 | 'AddOrder' => 'AddOrder', 191 | 'AddOrderResponse' => 'AddOrderResponse', 192 | 'AddOrderResult' => 'AddOrderResult', 193 | 'UpdateQuotation' => 'UpdateQuotation', 194 | 'UpdateQuotationResponse' => 'UpdateQuotationResponse', 195 | 'UpdateQuotationResult' => 'UpdateQuotationResult', 196 | 'AddOrder_DI' => 'AddOrder_DI', 197 | 'dsOrder' => 'dsOrder', 198 | 'AddOrder_DIResponse' => 'AddOrder_DIResponse', 199 | 'AddOrder_DIResult' => 'AddOrder_DIResult', 200 | 'ConsultaCliente' => 'ConsultaCliente', 201 | 'ConsultaClienteResponse' => 'ConsultaClienteResponse', 202 | 'ConsultaClienteResult' => 'ConsultaClienteResult', 203 | ); 204 | 205 | // This is the most important thing in this file: WSDL service discover URL. 206 | // Use your own URL for WSDL services. 207 | public function DiServerServicesSample($wsdl = "http://YOURSAPBOHOST/wsSalesQuotation/DiServerServices.asmx?WSDL", $options = array()) { 208 | foreach(self::$classmap as $key => $value) { 209 | if(!isset($options['classmap'][$key])) { 210 | $options['classmap'][$key] = $value; 211 | } 212 | } 213 | parent::__construct($wsdl, $options); 214 | } 215 | 216 | /** 217 | * Login to company 218 | * 219 | * @param Login $parameters 220 | * @return LoginResponse 221 | */ 222 | public function Login(Login $parameters) { 223 | return $this->__soapCall('Login', array($parameters), array( 224 | 'uri' => 'http://tempuri.org/wsSalesQuotation/Service1', 225 | 'soapaction' => '' 226 | ) 227 | ); 228 | } 229 | 230 | /** 231 | * LogOut to company 232 | * 233 | * @param LogOut $parameters 234 | * @return LogOutResponse 235 | */ 236 | public function LogOut(LogOut $parameters) { 237 | return $this->__soapCall('LogOut', array($parameters), array( 238 | 'uri' => 'http://tempuri.org/wsSalesQuotation/Service1', 239 | 'soapaction' => '' 240 | ) 241 | ); 242 | } 243 | 244 | /** 245 | * Get an XML document of an empty Quotation object 246 | * 247 | * @param GetEmptyQuotationXml $parameters 248 | * @return GetEmptyQuotationXmlResponse 249 | */ 250 | public function GetEmptyQuotationXml(GetEmptyQuotationXml $parameters) { 251 | return $this->__soapCall('GetEmptyQuotationXml', array($parameters), array( 252 | 'uri' => 'http://tempuri.org/wsSalesQuotation/Service1', 253 | 'soapaction' => '' 254 | ) 255 | ); 256 | } 257 | 258 | /** 259 | * Get an XML document of an empty Quotation object 260 | * 261 | * @param GetEmptyOrderXml $parameters 262 | * @return GetEmptyOrderXmlResponse 263 | */ 264 | public function GetEmptyOrderXml(GetEmptyOrderXml $parameters) { 265 | return $this->__soapCall('GetEmptyOrderXml', array($parameters), array( 266 | 'uri' => 'http://tempuri.org/wsSalesQuotation/Service1', 267 | 'soapaction' => '' 268 | ) 269 | ); 270 | } 271 | 272 | /** 273 | * Get an XML document of an empty Recordset object 274 | * 275 | * @param GetRecordsetXml $parameters 276 | * @return GetRecordsetXmlResponse 277 | */ 278 | public function GetRecordsetXml(GetRecordsetXml $parameters) { 279 | return $this->__soapCall('GetRecordsetXml', array($parameters), array( 280 | 'uri' => 'http://tempuri.org/wsSalesQuotation/Service1', 281 | 'soapaction' => '' 282 | ) 283 | ); 284 | } 285 | 286 | /** 287 | * Add Sales Quotation 288 | * 289 | * @param AddQuotation $parameters 290 | * @return AddQuotationResponse 291 | */ 292 | public function AddQuotation(AddQuotation $parameters) { 293 | return $this->__soapCall('AddQuotation', array($parameters), array( 294 | 'uri' => 'http://tempuri.org/wsSalesQuotation/Service1', 295 | 'soapaction' => '' 296 | ) 297 | ); 298 | } 299 | 300 | /** 301 | * Add Sales Order 302 | * 303 | * @param AddOrder $parameters 304 | * @return AddOrderResponse 305 | */ 306 | public function AddOrder(AddOrder $parameters) { 307 | return $this->__soapCall('AddOrder', array($parameters), array( 308 | 'uri' => 'http://tempuri.org/wsSalesQuotation/Service1', 309 | 'soapaction' => '' 310 | ) 311 | ); 312 | } 313 | 314 | /** 315 | * Update Quotation object 316 | * 317 | * @param UpdateQuotation $parameters 318 | * @return UpdateQuotationResponse 319 | */ 320 | public function UpdateQuotation(UpdateQuotation $parameters) { 321 | return $this->__soapCall('UpdateQuotation', array($parameters), array( 322 | 'uri' => 'http://tempuri.org/wsSalesQuotation/Service1', 323 | 'soapaction' => '' 324 | ) 325 | ); 326 | } 327 | 328 | /** 329 | * Add Sales Order DI 330 | * 331 | * @param AddOrder_DI $parameters 332 | * @return AddOrder_DIResponse 333 | */ 334 | public function AddOrder_DI(AddOrder_DI $parameters) { 335 | return $this->__soapCall('AddOrder_DI', array($parameters), array( 336 | 'uri' => 'http://tempuri.org/wsSalesQuotation/Service1', 337 | 'soapaction' => '' 338 | ) 339 | ); 340 | } 341 | 342 | /** 343 | * ConsultaCliente 344 | * 345 | * @param ConsultaCliente $parameters 346 | * @return ConsultaClienteResponse 347 | */ 348 | public function ConsultaCliente(ConsultaCliente $parameters) { 349 | return $this->__soapCall('ConsultaCliente', array($parameters), array( 350 | 'uri' => 'http://tempuri.org/wsSalesQuotation/Service1', 351 | 'soapaction' => '' 352 | ) 353 | ); 354 | } 355 | 356 | } 357 | 358 | ?> 359 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # phpDIServer 2 | 3 | The DI Server enables business partners to develop SOAP-based solutions to read, write, update, and remove data objects on the database level. It provides a suitable infrastructure for server-oriented partner solutions 4 | 5 | SAP Business One DI Server (Data Interface Server) is a Component Object Model (COM) service running on a server that enables multiple clients to access and manipulate SAP Business One company database, using SOAP version 1.1 messages. 6 | 7 | **phpDiServer** is a multifunctional wrapper to integrate SAP BO and DIServer with your application in PHP. 8 | With this code (AddOrderSap.php), you can develop and integrate on PHP multiple functions avaliables in DIServer 9 | 10 | ## Functionality included 11 | 12 | - Login 13 | - LoginResponse 14 | - LogOut 15 | - LogOutResponse 16 | - GetEmptyQuotationXml 17 | - GetEmptyQuotationXmlResponse 18 | - GetEmptyQuotationXmlResult 19 | - GetEmptyOrderXml 20 | - GetEmptyOrderXmlResponse 21 | - GetEmptyOrderXmlResult 22 | - GetRecordsetXml 23 | - GetRecordsetXmlResponse 24 | - GetRecordsetXmlResult 25 | - AddQuotation 26 | - AddQuotationResponse 27 | - AddQuotationResult 28 | - AddOrder 29 | - AddOrderResponse 30 | - AddOrderResult 31 | - UpdateQuotation 32 | - UpdateQuotationResponse 33 | - UpdateQuotationResult 34 | - AddOrder_DI 35 | - dsOrder 36 | - AddOrder_DIResponse 37 | - AddOrder_DIResult 38 | 39 | ## Requirements 40 | 41 | phpDiServer works with PHP >=5 and SOAP 1.1 / 1.2 and it can be used in WSDL or non-WSDL mode. 42 | 43 | ## Setup 44 | 45 | Change line 200 in DIServerService.php, use your SAP BO DiServerServices URL for WDSL, or modify YOURSAPBOHOST 46 | 47 | ```php 48 | $wsdl = "http://YOURSAPBOHOST/wsSalesQuotation/DiServerServices.asmx?WSDL" 49 | ``` 50 | 51 | ## Usage 52 | 53 | This is a simple example of usage where we use: 54 | 55 | - LOGIN (Login) 56 | - NEW ORDER (AddOrder) 57 | 58 | ```php 59 | require_once 'DiServerServices.php'; 60 | 61 | // Create DiServerService object 62 | $service = new DiServerServicesSample(); 63 | 64 | // Create Login Object with Service data 65 | $login= new Login(); 66 | $login->DataBaseServer=""; 67 | $login->DataBaseName=""; 68 | $login->DataBaseType=""; 69 | $login->DataBaseUserName=""; // string 70 | $login->DataBasePassword=""; // string 71 | $login->CompanyUserName=""; // string 72 | $login->CompanyPassword=""; // string 73 | $login->Language="23"; // string 74 | $login->LicenseServer="HOST:30000"; // Change HOST and port 75 | 76 | // Call to Login Service with the $login Object 77 | $IdSession=$service->Login($login)->LoginResult; 78 | 79 | // Check Here if $IdSession is OK. Otherwise, it had a problem 80 | // with login credentials 81 | 82 | // Create a new SAP Order 83 | $addOrder= new AddOrder(); 84 | // Order require Valid IDSession 85 | $addOrder->SessionID=$IdSession; 86 | 87 | // xmlOrderComposed is defined in another file: xmlorder_var.php 88 | // please see xmlorder_var.php, yo know how you can compose a XML order for 89 | // DiServer in SAP BO 90 | // You can paste the code in xmlorder_var.php here 91 | 92 | $addOrder->sXmlOrderObject=$xmlOrderComposed; 93 | 94 | $result=$service->AddOrder($addOrder); 95 | 96 | // In result->AddOrderResult->any and AddOrderResult 97 | // you have the XML SOAP code with the result of the order (ID, etc.) 98 | 99 | //echo $result->AddOrderResult->any; 100 | ``` 101 | 102 | ## License 103 | 104 | The MIT License (MIT) 105 | -------------------------------------------------------------------------------- /xmlorder_var.php: -------------------------------------------------------------------------------- 1 | ".date("Ymd").""; 33 | $xmlHeader = $xmlHeader."".date("Ymd").""; 34 | $xmlHeader = $xmlHeader."".$IdCostumer.""; 35 | $xmlHeader = $xmlHeader."0"; 36 | $xmlHeader = $xmlHeader."".$AgentCode.""; 37 | $xmlHeader = $xmlHeader."".$Comment.""; 38 | $xmlHeader = $xmlHeader."".$Addrs.""; 39 | 40 | // Compose DOCUMENT with xmlHeader (order header) 41 | $xmlHeaderComposed="".$xmlHeader.""; 42 | 43 | 44 | // Here, we compose order lines 45 | $orderLines=""; 46 | foreach ($orderLinesList as $lin) { 47 | $orderLines= $orderLines.""; 48 | $orderLines= $orderLines."".$lin->ItemCode.""; 49 | $orderLines= $orderLines."".$lin->qty.""; 50 | $orderLines= $orderLines."".$lin->dsc.""; 51 | $orderLines= $orderLines.""; 52 | } 53 | 54 | 55 | // Compose Order Lines 56 | $xmlorderLinesComposed="".$orderLines.""; 57 | 58 | 59 | // Finally we compose the whole order 60 | $xmlOrderComposed="oOrders".$xmlHeaderComposed.$xmlorderLinesComposed.""; 61 | 62 | 63 | ?> --------------------------------------------------------------------------------