Click here to Skip to main content
15,894,740 members
Articles / Productivity Apps and Services / Sharepoint

PHP Web Service WSDL Generator / SOAP Server (Document/Literal)

Rate me:
Please Sign up or sign in to vote.
4.80/5 (11 votes)
7 Feb 2013CPOL6 min read 195.1K   6.2K   14  
Generates the required WSDL file and SOAP server for receiving data from InfoPath (Document/Literal format).
<?php

ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("http://localhost/wsdl.php?WSDL");	// Locate WSDL file to learn structure of functions
$server->addFunction("ChooseColour");	// Same func name as in our WSDL XML, and below
$server->handle();  

function ChooseColour($formdata) {
    $attempt = false; // File writing attempt successful or not
    $formdata = get_object_vars($formdata); // Pull parameters from SOAP connection
    
    // Sort out the parameters and grab their data
    $myname = $formdata['Name']; 
    $mycolour = $formdata['FavColour'];
    $mynumber = $formdata['FavNumber'];
    
    $str =  "Name: " . $myname . ", ";
    $str .= "Colour: " . $mycolour . ", ";
    $str .= "Number: " . $mynumber . "\r\n";
    
    $filename = "./formdata.txt";
    if (($fp = fopen($filename, "a")) == false) return array('Success' => false);
    if (fwrite($fp, $str)) {
    	$attempt = true;
    }
    fclose($fp);     

    return array('Success' => $attempt);
}

?>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer
Australia Australia
I work in civil aerial Search and Rescue as a special missions equipment instructor.
IT and coding is my passion/hobby.

I am one of those fortunate enough to be able to mix my passion with my career, by developing custom software / services for use within my company.

Comments and Discussions