2

We are considering the use of Microsoft Dynamics GP 10 Web Services and will want to use PHP to create / update customers and sales... So the question is: Is this possible and if so does anyone know of good documentation out there?

I am not finding anything out there with using PHP, another part of this question would be security credentials and if PHP can correctly pass the needed login and fully interact with GP's web service?

Any ideas or known resources?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Chad Smith
  • 177
  • 10
  • PHP can interact with websites quite easily (but tediously). The question is if it's worth your time getting it to do so with GP. – Marc B Aug 23 '11 at 22:08
  • @Marc - I guess the question there is how tedious is tedious :) If it is slightly tedious we may be ok with that. I guess most people using GP web services are using .net so I just cant find documentation on using PHP with it. Microsoft's docs all seem to be .net centered so that isn't much help. Before we dive in i guess i just want to know the water is somewhat swim-able. – Chad Smith Aug 23 '11 at 22:14
  • Unless you can find an API library for it somewhere, yhou'd be stuck trying to recreate a browser in PHP to simulate someone sitting at a real browser and clicking around/entering/changing data... e.g... tedious. – Marc B Aug 23 '11 at 22:16

2 Answers2

4

For what it's worth, I use a set of stored procedures called eConnect to do GP integrations. It may not be the most elegant solution, but it works fairly good. eConnect is also documented pretty well by Microsoft.

If you choose to use this kind of integration, it is wise to get familiar with the Dexterity Application. Learning the Dexterity Application helps a lot with object and table mappings and it should be a free download from Customer Source.

Here is an example of an eConnect stored procedure to create a customer record:

$sql = "declare @p115 int
set @p115=0
declare @p116 varchar(255)
set @p116=''                                                                                                             
exec dbo.taUpdateCreateCustomerRcd
@I_vCUSTNMBR = '123456',
@I_vCUSTNAME = 'Company Name',
@O_iErrorState = @p115 OUTPUT,                                                                  
@oErrString = @p116 OUTPUT                                                                                       

select @p115, @p116";

To execute it just do something like the following (using PHP ADODB in this example):

    gp_execute_sp($sql);


    function gp_execute_sp($sql, $transactions = true) {
        global $DBGP;

        if($transactions)
            $DBGP->StartTrans();
            $rs = $DBGP->Execute($sql);
                if(is_object($rs) && !$rs->EOF) {
                        if($rs->fields['computed'] != 0) {
                if($transactions)
                                    $DBGP->FailTrans();
                                throw new Exception(get_error_desc($rs->fields['computed']));            

                        }                                                                                                
                } elseif(!is_object($rs)) {                                                                              
            if($transactions)                                                                                            
                            $DBGP->FailTrans();                                                                          
                        throw new Exception("Database Connection Error.");

                } else {                                                                                                 
                    if($transactions)                                                                                    
                    $DBGP->FailTrans();                                                                                  
                        throw new Exception("Stored proceedure did not return a result.");                               
                }                                                                                                        

                if($transactions)                                                                                        
                    $DBGP->CompleteTrans(); 
   }

   function get_error_desc($value) {
        global $DBGP;

        if(is_numeric($value)) {
            $result = "No Error Available";
            $sql = "SELECT ErrorDesc FROM DYNAMICS..taErrorCode WHERE ErrorCode=?";
            $rs = $DBGP->execute($sql, array($value));
            if(!$rs->EOF) {
                $result = $rs->fields['ErrorDesc'];
            }
        } else {
            $result = $value;
        }

        return $result;
    }
0

I have not yet used Dynamics GP but based on my reding of the developer guide there is a legacy endpoint and a native endpoint but both are SOAP services so I see no reason why you couldn't use PHP's SOAP client.

$client = new SoapClient('http://machine_name:<port_number>/Dynamics/GPService');
$result = $client->GetCompanyList(...);

I do not know what goes at ..., but again there is no reason the above shouldn't be possible since SOAP is designed to work with most languages including PHP, it just won't be as simple as it could be.

EDIT: It may be helpful to use a WSDL to PHP class generator. See: generate php code from wsdl

Community
  • 1
  • 1
ColinM
  • 13,367
  • 3
  • 42
  • 49