Jump to content

Call Web service in PHP using nusoap


rsingh

Recommended Posts

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]

Link to comment
https://forums.phpfreaks.com/topic/119266-call-web-service-in-php-using-nusoap/
Share on other sites

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






Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.