?
Solved

How to call soapclient function using NuSoap?

Posted on 2009-12-20
7
Medium Priority
?
3,335 Views
Last Modified: 2013-11-18
Dear Experts,

I am integrating an Gunbrokers Soap API(http://apiv2.gunbroker.com/) with my website.
I have some problems integrating it.


I dont know where I went wrong. Any solution to fix this?  I mean, can I use any other soap function other than nusoap.

Any answers would be appreciated.


On the API, it is given the XML format for the login function as
----------------------------------------------
POST /AuctionService.asmx HTTP/1.1
Host: apiv2.gunbroker.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "GunBrokerAPI_V2/Login"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Login xmlns="GunBrokerAPI_V2">
      <UserName>string</UserName>
      <Password>string</Password>
      <DevKey>string</DevKey>
      <AppKey>string</AppKey>
    </Login>
  </soap:Body>
</soap:Envelope>

------------------------------------------------------

/*
I am using nuSoap,

So I made the call like this,

*/

$username = 'USERname';
$password = 'XXXXXX';
$devkey = 'asasass-xxxxx4xxxx-x-x-x-x--xf';
$appkey = 'xxxxx-x--x-xxxxx-x-xxxx-xxxxxx-x';
		
$login = array('UserName'=>$username,'Password'=>$password,'DevKey'=>$devkey,'AppKey'=>$appkey);	

$client = new nusoap_client('http://apiv2.gunbroker.com/AuctionService.asmx?WSDL');
	
if ($err) 	{
   // Display the error
   echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}

$result = $client->call('Login',$login, "GunBrokerAPI_V2","GunBrokerAPI_V2/Login",false,null,'rpc','encoded');


print_r($result);

/*
The response is

Array
(
    [Timestamp] => 2009-12-21T01:20:17.1396683-05:00
    [Ack] => Failure
    [Errors] => Array
        (
            [ShortMessage] => GunBrokerAPI_V2 Error Message : [Login]
Login failed.
            [ErrorCode] => 1
        )

    [User] => Array
        (
            [HadTransactionWithUser] => false
            [UserID] => 0
            [Status] => 0
            [FeedbackScore] => 0
            [FeedbackRating] => 0
            [RegistrationDate] => 0001-01-01T00:00:00
        )

)
*/

Open in new window

0
Comment
Question by:kumaranmca
7 Comments
 
LVL 1

Accepted Solution

by:
devteam earned 2000 total points
ID: 26097503
NuSOAP is strictly for PHP 4.
PHP 5 uses its own Soap engine (with an extension)

If you use NuSOAP, use the code attached


NuSOAP download link:
http://sourceforge.net/projects/nusoap/
require_once('lib/nusoap.php');

// A = URL Link to call
// B and C = if you use basic authentication to connect to the soap server, set it there. Otherwise don't include that line at all.
$clientSOAP = new soapclient("A", true);
$clientSOAP->setCredentials('B', 'C', 'basic');

// This is an example of the parameters required by your soap function (in this case it required a username, password and did)
	$params = array (
					"username" => "D",
					"password" => "E",
					"did" => "F"
			  );	
// then call your method from the WSDL, and bind the $params to it.		
	$myres = $clientSOAP->call("getAccess", $params);

	// Displays the content of the request and responce messages. Used for debugging
	function displayMessageInfo($client, $result)
	{
		echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
		echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';


		echo "<b>RESPONSE:</b> ";
		print_r($result);
		echo "<br><br>";
	}
// This is debugging information if you want to see it.
	//displayMessageInfo($clientSOAP, $myres);
	
	//if an error is returned, display it. Otherwise, execute code.
	if ($client->fault)
	{
		echo '<h2>Fault (This is expected)</h2><pre>'; print_r($result); echo '</pre>';
	}
	else
	{
// put your code here. Expect the returned array from your soap response.
}

Open in new window

0
 
LVL 2

Expert Comment

by:pallavanj
ID: 26130379
Hello devteam,

I have the same problem with the gunbroker API.

My PHP version is 5.2.5, So we cannot use the nuSoap, Right?
0
 
LVL 2

Expert Comment

by:pallavanj
ID: 26136182
Hello devteam,

Since kumaranmca got the response, I hope soap is working.

Is there any error with the constructed array $login;

please help
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Author Comment

by:kumaranmca
ID: 26136213
Still getting the same response,

Iam repeatedly refering the api http://apiv2.gunbroker.com/, not able to get the soln.
please tell me how to form the array for the following xml

POST /AuctionService.asmx HTTP/1.1
Host: apiv2.gunbroker.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "GunBrokerAPI_V2/Login"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Login xmlns="GunBrokerAPI_V2">
      <UserName>string</UserName>
      <Password>string</Password>
      <DevKey>string</DevKey>
      <AppKey>string</AppKey>
    </Login>
  </soap:Body>
</soap:Envelope>


Is the below line right?

$login = array('UserName'=>$username,'Password'=>$password,'DevKey'=>$devkey,'AppKey'=>$appkey);

Open in new window

0
 
LVL 8

Author Comment

by:kumaranmca
ID: 26136412
My PHP info

phpinfo.bmp
0
 
LVL 83

Expert Comment

by:leakim971
ID: 26505539
NuSoap > your PHP Version is 5.2.5

Did you saw first @devteam comment ?
0
 
LVL 8

Author Closing Comment

by:kumaranmca
ID: 31668413
you are a star!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question