Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Web Services using nusoap

Posted on 2003-11-09
3
Medium Priority
?
242 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 1000 total points
ID: 9719167
try replacing <form method=get action=".$PHP_SELF."> with <form method=get action=".$_SERVER["PHP_SELF"].">

loz
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
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 …

671 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