rsingh Posted August 12, 2008 Share Posted August 12, 2008 I am facing a problem to call a web service (asmx - dotnet) in using nusoap library in PHP. Could you please help me to sort out this? When I call this in dot net(C#) it is called successfully. I think the problem is in webservice structure but not confirm. Below is information about WSDL http://merchantapi.rega-staging.polipayments.com/MerchantAPIService.asmx?WSDL Method of webservice: InitiateTransaction When you would see the WSDL structure you would find that the method would take two parameters one is authentication code and other one is a complextype. This complex type would take a list of parameters and this is my confusion point. I am receiving following error : Array ( [faultcode] => soap:Server [faultstring] => An error has occurred. Please try again later. [faultactor] => Centricom.POLi.Services.MerchantAPI.MerchantAPIService:InitiateTransaction [detail] => 8001 ) I am using following code to call this: MerchantCode and Authanticationcode are dummy in this. I have also attached the code. <?php include_once('nusoap/nusoap.php'); $soapClient = new nusoap_client('http://merchantapi.rega-staging.polipayments.com/MerchantAPIService.asmx?WSDL', true); $err = $soapClient->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; exit; }else { echo "<h2>Successfully connected</h2>"; } $soapClient->debug_flag = true; $params['MerchantCode'] = 'demo'; $params['MerchantRef'] = '123'; $params['MerchantData'] = '123'; $params['CurrencyCode'] = 'AUD'; $params['CurrencyAmount'] = 1; $params['MerchantDateTime'] = '2008-08-07'; $params['SuccessfulURL'] = 'http://yahoo.com'; $params['NotificationURL'] = 'http://yahoo.com'; $params['UnsuccessfulURL'] = 'http://yahoo.com'; $params['MerchantCheckoutURL'] = 'http://yahoo.com'; $params['MerchantHomePageURL'] = 'http://yahoo.com'; $params['UserIPAddress'] = '127.0.0.1'; $params['Timeout'] = '3000'; $sendData = array('AuthenticationCode'=>’dummy', 'Transaction'=>$params); try { $result = $soapClient->call('InitiateTransaction', $sendData); if ($soapClient->fault) { echo "<h3>Fault</h3><hr />"; print_r($result); }else { echo "<h3>Success</h3><hr />"; print_r($result); } } catch(Exception $e) { echo "<pre>"; print "Request: <br />" . nl2br(htmlspecialchars($soapClient->__getLastRequest())) . "<br /><br />"; print "Response: <br />" . nl2br(htmlspecialchars($soapClient->__getLastResponse())) . "<br /><br />"; echo "</pre>"; die($e); } echo '<h3>Request</h3><hr />'; echo '<pre>' . htmlspecialchars($soapClient->request, ENT_QUOTES) . '</pre>'; echo '<h3>Response</h3><hr />'; echo '<pre>' . htmlspecialchars($soapClient->response, ENT_QUOTES) . '</pre>'; echo '<h3>Debug</h3><hr />'; echo '<h2>Debug</h2><pre>' . htmlspecialchars($soapClient->debug_str, ENT_QUOTES) . '</pre>'; ?> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/119266-call-web-service-in-php-using-nusoap/ Share on other sites More sharing options...
ignace Posted August 12, 2008 Share Posted August 12, 2008 add code tags to your code Quote Link to comment https://forums.phpfreaks.com/topic/119266-call-web-service-in-php-using-nusoap/#findComment-614582 Share on other sites More sharing options...
rsingh Posted August 13, 2008 Author Share Posted August 13, 2008 Hello ignace, Thank you for your reply. Could you please elaborate more this? I could not get for which code tag you are talking. Quote Link to comment https://forums.phpfreaks.com/topic/119266-call-web-service-in-php-using-nusoap/#findComment-615224 Share on other sites More sharing options...
TheUnknown Posted August 13, 2008 Share Posted August 13, 2008 [code*][*/code] he means add the above to the code so its readable Quote Link to comment https://forums.phpfreaks.com/topic/119266-call-web-service-in-php-using-nusoap/#findComment-615227 Share on other sites More sharing options...
rsingh Posted August 13, 2008 Author Share Posted August 13, 2008 Oh. I am posting the code again using code tag. Please have a look in this and suggest me. I am stumped with this problem. include_once('nusoap/nusoap.php'); $soapClient = new nusoap_client('http://merchantapi.rega-staging.polipayments.com/MerchantAPIService.asmx?WSDL', true); $err = $soapClient->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; exit; }else { echo "<h2>Successfully connected</h2>"; } $soapClient->debug_flag = true; $params['MerchantCode'] = 'demo'; $params['MerchantRef'] = '123'; $params['MerchantData'] = '123'; $params['CurrencyCode'] = 'AUD'; $params['CurrencyAmount'] = 1; $params['MerchantDateTime'] = '2008-08-07'; $params['SuccessfulURL'] = 'http://yahoo.com'; $params['NotificationURL'] = 'http://yahoo.com'; $params['UnsuccessfulURL'] = 'http://yahoo.com'; $params['MerchantCheckoutURL'] = 'http://yahoo.com'; $params['MerchantHomePageURL'] = 'http://yahoo.com'; $params['UserIPAddress'] = '127.0.0.1'; $params['Timeout'] = '3000'; $sendData = array('AuthenticationCode'=>’dummy', 'Transaction'=>$params); try { $result = $soapClient->call('InitiateTransaction', $sendData); if ($soapClient->fault) { echo "<h3>Fault</h3><hr />"; print_r($result); }else { echo "<h3>Success</h3><hr />"; print_r($result); } } catch(Exception $e) { echo "<pre>"; print "Request: <br />" . nl2br(htmlspecialchars($soapClient->__getLastRequest())) . "<br /><br />"; print "Response: <br />" . nl2br(htmlspecialchars($soapClient->__getLastResponse())) . "<br /><br />"; echo "</pre>"; die($e); } echo '<h3>Request</h3><hr />'; echo '<pre>' . htmlspecialchars($soapClient->request, ENT_QUOTES) . '</pre>'; echo '<h3>Response</h3><hr />'; echo '<pre>' . htmlspecialchars($soapClient->response, ENT_QUOTES) . '</pre>'; echo '<h3>Debug</h3><hr />'; echo '<h2>Debug</h2><pre>' . htmlspecialchars($soapClient->debug_str, ENT_QUOTES) . '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/119266-call-web-service-in-php-using-nusoap/#findComment-615316 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.