Solved

Web Services using nusoap

Posted on 2003-11-09
3
240 Views
Last Modified: 2008-03-03
The code below is intented to provide me with capacity to consume a webservice with textanywhere.net.

I would like to enable the capability to check the validity of a Mobile Phone Number that could be located anywhere in the world.  On execution, I get no response.  I'm sure that my code is not correct.  Can someone identify what is wrong with it.  the code for the webservice is located         at: http://ws.textanywhere.net/ta_sms.asmx
live example at: http://ws.textanywhere.net/sample.asp

I am using php

Michael Senyonjo
==============================================
 <?php
/* Coucou les copains :) c'est trop facile le php :)
* Company Information
* This script is a webservice client that consumes the webservice with
* WSDL document at http://www.flash-db.com/services/ws/companyInfo.wsdl 
* http://ws.textanywhere.net/ta_sms.asmx
* Given any mobile phone number, it queries the webservice for information about
* that number  and it retrieves the results from the webservice
* for display.
*
* A live demo of this program can be found at
* http://ws.textanywhere.net/sample.asp
*
*
*/

 // Include the NuSOAP soap toolkit file.
require_once('nusoap.php');

 // Create a SOAP Client object.
 $client = new soapclient("http://ws.textanywhere.net/TA_WS");

 // The following is a mechanism for capturing the stock symbol we want
 // to lookup. You can change this as required.
 $number = $_GET['number'];

 // Arguments for the webservice.
 $param = array ("username"=>"Lxxxxx3", "pyyyyyd"=>"51xo0n3", "ticker"=>$number);

 // Call the webservice "textanywhere.net/TA_WS" method with the arguments.
 $results = $client->call("textanywhere.net/TA_WS", $param);

 /* $results is an array with the following structure

*/

 // We would now format the data for output in HTML.
 $html = "<html>\n<head>\n<title>Mobile Phone Number Information. Webservice client - Written by: Tim Akinbo</title>\n</head>\n";
 $html .= "<body>\n";
 $html .= "<table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width=\"300\" bgcolor=\"#CCCCCC\">\n<tr>\n";
 $html .= "<td><font face=\"Tahoma, Arial\" size=\"2\">&nbsp;Mobile Phone Number Information</font></td>\n";
 $html .= "</tr>\n<tr>\n<td>\n<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" width=\"100%\" bgcolor=\"#FFFFFF\">\n<tr>\n";
 $html .= "<td><font face=\"Tahoma, Arial\" size=\"1\"><strong>Phone Number</strong></font></td><td><font face=\"Tahoma, Arial\" size=\"1\"><strong>Country</strong></font></td><td><font face=\"Tahoma, Arial\" size=\"1\"><strong>Credit Available</strong></font></td>\n</tr>\n";

 $color = "#000000";

 // $color is set to green if we have an appreciation in value (number is present in $results['textanywhere.net/TA_WS'])
 //if (preg_match("/^\+/", $results['changePercent'])) $color = "#00CC33";
 //if ($number == ($results = $client->call("textanywhere.net/TA_WS", $param))  $color = "#00CC33";
 if (preg_match("$number", $results['textanywhere.net/TA_WS'])) $color = "#00CC33";

 // else it is set to red if we have a depreciation ("-")
 //if (preg_match("/^-/", $results['changePercent'])) $color = "#FF0000";

 $html .= "<tr>\n<td><font face=\"Tahoma, Arial\" size=\"1\">" . $results['number'] . "</font></td><td><font face=\"Tahoma, Arial\" size=\"1\">" . $results['country'] . "</font></td><td><font face=\"Tahoma, Arial\" size=\"1\" color=\"$color\"><strong>" . $results['credit'] . "</strong></font></td>\n</tr>\n";
 $html .= "</table>\n</td>\n</tr>\n</table>\n</body>\n<form method=get action=".$PHP_SELF."><font face=\"Tahoma, Arial\" size=\"1\"><strong>Number to Call : (must start with '+')</strong></font><input type=text name=number><input type=submit value=Check Number></form></html>";

 echo $html;
?>

Michael
==========
0
Comment
Question by:Senyonjo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Accepted Solution

by:
lozloz earned 250 total points
ID: 9719167
try replacing <form method=get action=".$PHP_SELF."> with <form method=get action=".$_SERVER["PHP_SELF"].">

loz
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

626 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