how to use curl php nusoap web service-hello world-free php script

Here you will find a  free php scripts, php resources, php tutorials, web resources , jquery

PHP Script :

<?php print "welcome to source world-free php scripts"; ?>

PHP (recursive acronym for PHPHypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

Instead of lots of commands to output HTML (as seen in C or Perl), PHP pages contain HTML with embedded script that does "something" (in this case, output "Hi, I'm a PHP script!"). The PHP script is enclosed in special start and end processing instructions  and ?> that allow you to jump into and out of "PHP mode."

In PHP script there is mainly two way to communicate with different different protocol  1)socket  and 2)Curl. Here this php script shows how to use nusoap curl together for web-service.
Free php script programming-web service

What is PHP  CURL?

PHP Script supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.These functions have been added in PHP 4.0.2. 

You can also use this script in php AJAX.PHP AJAX is great way to call web service.

You can also use this free php scripts to your free php cms software developments .This is free php scripts.This free php scripts does not take any kind of responsibilities You can always use on your own risk.You can reports bug to me for this free php scripts.  

How to use CURL in Nusoap PHP script Web Service?

Php nusoap web service using curl

Note:PHP Web services required NuSoap Library Download it from  

Download Nusoap Lib

Just Set Client object curl property to true.


PHP Script-hello world using curl


//include required class for build nnusoap web service server
// Create server object
$server = new soap_server();
// configure  WSDL
$server->configureWSDL('hello world', 'urn:hellowsdl');
// Register the method to expose
$server->register('hello_world',                    // method
    array('name' => 'xsd:string'),                 // input parameters
    array('return' => 'xsd:string'),              // output parameters
    'urn:hellowsdl',                             // namespace
    'urn:hellowsdl#hello',                // soapaction
    'rpc',                                    // style
    'encoded',                              // use
    'Says hello world to client'            // documentation
// Define the method as a PHP function

function hello_world($pName) {
            return 'Hello world from, ' . $pName;
// Use the request to (try to) invoke the service


  // includes nusoap class

// Create object
$client = new nusoap_client('http://localhost:80/webservice/nusoap/server/server.php?wsdl', true);

//use curl --set here to true

// Check for an error
$err = $client->getError();
if ($err) {
    // error if any
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
// Call mathod
$result = $client->call('hello_world', array('name' => 'Nik'));
// fault if any
if ($client->fault) {
    echo '<h2>Fault</h2><pre>';
    echo '</pre>';
} else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo '<h2>Error</h2><pre>' . $err . '</pre>';
    } else {
        // Display the result
        echo '<h2>Result</h2><pre>';
    echo '</pre>';

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account

No comments:

Post a Comment