Pages

Search This Blog

Sunday, September 27, 2009

phpsoap: retrieve returned array data

Well, i'm newbie in soap especially phpsoap. I'm facing problem to retrieve data returned from a soap api written in .net. I can see the whole data printed out by using print_r but i'm not able to get the each data from the array returned.

Situation:
I want to get the data returned by the soap server in array form after i've called the function "GetAccountInfo" by passing in parameter "AccoundID" by using phpsoap client.
My soap server url: http://10.10.100.101/soapserver.asmx

below are the code that i can get the data printed out.
<?php
$ini = ini_set("soap.wsdl_cache_enabled","0");

//instantiate the SOAP client
$client = new SoapClient("http://10.10.100.101/soapserver.asmx?WSDL");

$params = array();
$params["AccountID"] = "inblues";

$result = $client->GetAccountInfo($params);
print_r ($result ->GetAccountInfoResult);

?>

Output on the browser:


Array (
[GetAccountInfoResult] => Array (
[memberData] => Array (
[lastlogin] => 6/19/2009 2:10:51 AM
[lastip] => 219.95.192.254
[datecreated] => 6/19/2009 2:10:51 AM
[active] => 1
)
)
)



But what i want is only [active] field's data. What can i do? Finally, by looking at the printed result and by try and error, i found out that it's a 3 dimensional array, below code helps me to get the data i want.

<?php
$ini = ini_set("soap.wsdl_cache_enabled","0");

//instantiate the SOAP client
$client = new SoapClient("http://10.10.100.101/soapserver.asmx?WSDL");

$params = array();
$params["AccountID"] = "inblues";

$result = $client->GetAccountInfo($params);

// the result is in 3 dimensional array
print_r ($result->GetAccountInfoResult->memberData-> active);

?>

Solve. I get my value 1 printed out in the browser.

Friday, September 25, 2009

remove "Google Toolbar" from firefox

Open Mozilla Firefox,
Go to Tools Menu, Click On Add-ons




A new Add-ons windows popup, Select "Google Toolbar for firefox" and click on Unistall button.



Done. Hope this help.

Thursday, September 3, 2009

The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use .. pool

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool.
This may have occurred because all pooled connections were in use and max pool size was reached.

My web app written is ASP.NET C# and database use MySQL.

To solve it. Close all your connection each time you have finishing your query.

Monday, August 24, 2009

Sys.WebForms.PageRequestManagerServerErrorException: an unknow error occured while processing the request on the server. ..status code returned .. 500

My situation:
Environment: ASP.NET, AJAX.NET and MySQL DB

I got error return when using one of the form written in AJAX.NET when calling MySQL Stored Procedure

Sys.WebForms.PageRequestManagerServerErrorException: an unknow error occured while processing the request on the server. the status code returned from the server was: 500



Well, after check around i found out that the problem is in the MySQL Stored Procedure case sensitive issue. Change the case and problem solved!

Wednesday, August 19, 2009

phpmyadmin and stored procedure

As far as i know, we are not able to view, edit stored procedure using phpmyadmin but we are able to drop/create stored procedure using phpmyadmin.

I try to create a mysql stored procedure using phpmyadmin and hit error below

Error

SQL query:

DELIMITER;

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1




my original code:

DELIMITER $$

DROP PROCEDURE IF EXISTS `xxxweb`.`pp_pspbatch` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pp_pspbatch`(
IN pBatchName VARCHAR(255),
IN pCountryID INT
)
BEGIN

xxxxx
xxxxx
xxxxx

END $$
DELIMITER ;

try below steps, it help to solve my problem
1. Go to any SQL tab in phpMyAdmin.
2. Directly below the SQL text area you'll see a text input labeled "Delimiter." In that field, enter "$$".





3. Modify the script become like below

DROP PROCEDURE IF EXISTS `xxxweb`.`pp_pspbatch` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pp_pspbatch`(
IN pBatchName VARCHAR(255),
IN pCountryID INT
)
BEGIN

xxxxx
xxxxx
xxxxx

END $$

and run it. It works.

Wednesday, July 22, 2009

SmarterMail not receiving mails but can send out email

Well, set up my smartermail in new windows 2003 server. I've already make sure steps provided in Smartermail help file properly set.

WebMail URL (A Record) - Add an A or CNAME record for mail.example.com that points to the IP address of the webmail interface. This will allow users of that domain to access the webmail by typing in http://mail.example.com or http://mail.example.com:9998 in their web browser (depending on whether you use the included web server or IIS).

Mail Pointer (MX Record) - Add an MX record for example.com that points to the IP address that you assigned when adding the domain to SmarterMail. This will allow other email servers to locate your mail server.

Reverse DNS Record - Add a reverse DNS record for IP addresses assigned on the server to provide extra assurance to other mail servers. Also, it is recommended that the primary IP address of the server also have a reverse DNS record. Note: Adding reverse DNS may also require a change at your isp.


Also already setup iis to able login thru specific domain. Things work fine, able to send out email but not able to received email from external domain that not in the server. Strange, huh?

After check here and there, finally find out that we need to enable port in windows firewall.

Well, open my windows firewall and add in "Exceptions" to the port correctly. For my case, i just enable the port for below port



It's work. Hope can help.


Monday, July 13, 2009

#1064 - You have an error in your SQL syntax; xxx corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1

I try to create a mysql stored procedure using phpmyadmin and hit error below

Error

SQL query:

DELIMITER;

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1




my original code:

DELIMITER $$

DROP PROCEDURE IF EXISTS `xxxweb`.`pp_pspbatch` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pp_pspbatch`(
IN pBatchName VARCHAR(255),
IN pCountryID INT
)
BEGIN

xxxxx
xxxxx
xxxxx

END $$
DELIMITER ;

try below steps, it help to solve my problem
1. Go to any SQL tab in phpMyAdmin.
2. Directly below the SQL text area you'll see a text input labeled "Delimiter." In that field, enter "$$".





3. Modify the script become like below

DROP PROCEDURE IF EXISTS `xxxweb`.`pp_pspbatch` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pp_pspbatch`(
IN pBatchName VARCHAR(255),
IN pCountryID INT
)
BEGIN

xxxxx
xxxxx
xxxxx

END $$

and run it. It works.

Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

this will happen in linux server when the owner permissions is set to read/write/execute only. There is no public and group permissions setting. To solve this, i can the permissions to 755.

Problem solved.

Thursday, July 2, 2009

Reverse 2 dimentional array in C/C++

I need to reverse 2 dimentional array in C/C++.
Example: i need to reverse
10010110 t0 01101001
10000000 to 00000001

my 2 dimention array:

myArray[0][0] = 1
myArray[0][1] = 0
myArray[0][2] = 0
myArray[0][3] = 1
myArray[0][4] = 0
myArray[0][5] = 1
myArray[0][6] = 1
myArray[0][7] = 0

myArray[1][0] = 1
myArray[1][1] = 0
myArray[1][2] = 0
myArray[1][3] = 0
myArray[1][4] = 0
myArray[1][5] = 0
myArray[1][6] = 0
myArray[1][7] = 0

//in main
void main()
{

//call function
reverseArray(myArray, 2);

}

// function reverseArray
void reverseArray(char array[][8], int row) {
int i;
int j;
int size;
char swap;

for (j = 0; j<=(row-1); j++)
{

i=0;
size = 8;

for(i;i<--size;i++)
{
swap=array[j][i];
array[j][i]=array[j][size];
array[j][size]=swap;
}
}
}

this return the value i need. Hope this help

Friday, June 5, 2009

PHP call external cgi and process responses

This is tough for me. First time to code in PHP with cgi and don't know how to start. Thanks google for this.

My task is call a cgi script to execute some function and process the return data. Well, here i'll mention on how to call external cgi and the process part can be settled using PHP string processing.

Let's start by example:

cgi domain location: www.xincube.com/script/handler/api.cgi

The code will strip header below and return the content of the response data.

HTTP/1.1 200 OK
Date: Sat, 06 Jun 2009 02:23:33 GMT
Server: Apache
Proxy-x-forwarded-for: 203.116.10.206
X-returncode: 0
X-returndesc: Access denied
Cache-control: no-cache
Pragma: no-cache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain

We can do anything we want to get the information we need in $content.

CODE:

/* sample for calling cgi */
$host = 'www.xincube.com';
$path = '/scripts/handler/API.cgi';

$data_to_send = 'action=GetSupportedData';


PostToHost($host, $path, $data_to_send);

/* function that will call cgi */
function PostToHost($host, $path, $data_to_send) {

$header = "not yet";
$content = '';
$fp = fsockopen($host,80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)\n";
}
else {
fputs($fp, "POST $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: ".strlen($data_to_send)."\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, $data_to_send);

while(!feof($fp)) {
//echo fgets($fp, 4000);
$line = fgets( $fp, 4000 );
if( $line == "\r\n" && $header == "not yet" ) {
$header = "passed";
}
if( $header == "passed" ) {
$content .= $line;
}
}
echo $content;
fclose($fp);
}
}


Hope this help. Support me to write more by clicking on the ads sponsor or donation. Thanks