开发者

Microsoft Dynamics GP 10 WebServices using PHP

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?


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;
    }


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜