Click here to Skip to main content
15,888,221 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any class of methor in PHP to generate WSDL file???
Posted

The first hit on Google when searching for "wsdl class php[^]" seems to be what you are after.

http://www.phpclasses.org/browse/package/3509.html[^]
 
Share this answer
 
I m trying to create a helloworld
ASM
Web service using that class, i have created WSDL file ...
But Unable to call it from client End


HelloWorldClass.php

MIDL
<?php
    class HelloWorldClass
    {
        /**
         * Get the example
         *
         * @return string
         */
        public function printHello()
        {
            return 'Hello User';
        }
        /**
         * Adds two numbers
         *
         * @param float $p1
         * @param float $p2
         * @return float
         */
        public function add($p1, $p2) {
            return ($p1+$p2);
        }
    }
?>


index.php to create WSDL using wsdlCreater Class

<?php
require_once('WSDLCreator.php');

$WSDLCreator = new WSDLCreator("myTestWsdl", "http://192.168.1.49/php2wsdl");
$WSDLCreator -> addFile("HelloWorldClass.php");
$WSDLCreator -> addURLToClass('HelloWorldClass',"http://192.168.1.49/php2wsdl/HelloWorldClass.php");
$WSDLCreator -> addURLToTypens("XMLCreator", "http://192.168.1.49/php2wsdl");
$WSDLCreator -> createWSDL();
$WSDLCreator -> printWSDL(true);
?>


SoapClient.PHP

XML
<?php
    try
    {
        $client =   new SoapClient("http://192.168.1.49/php2wsdl/");
        echo "<pre>";
        echo $client    ->__soapCall('printHello',array());
    }
    catch (Exception $e)
    {
        echo $e->getMessage()."<br><pre>";
    }
?>


GENERATED WSDL FILE:--

XML
<definitions name="myTestWsdl" targetNamespace="urn:myTestWsdl"><message name="add">
<part name="p1" type="xsd:float"/>
<part name="p2" type="xsd:float"/>
</message><message name="addResponse">
<part name="addReturn" type="xsd:float"/>
</message>
<message name="printHello"/><message name="printHelloResponse">
<part name="printHelloReturn" type="xsd:string"/>
</message><portType name="HelloWorldClassPortType"><operation name="add">
<documentation>Adds two numbers</documentation>
<input message="typens:add"/>
<output message="typens:addResponse"/>
</operation><operation name="printHello">
<documentation>Get the example</documentation>
<input message="typens:printHello"/>
<output message="typens:printHelloResponse"/>
</operation>
</portType><binding name="HelloWorldClassBinding" type="typens:HelloWorldClassPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="add">
<soap:operation soapAction="urn:HelloWorldClassAction"/><input>
<soap:body namespace="urn:myTestWsdl" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input><output>
<soap:body namespace="urn:myTestWsdl" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation><operation name="printHello">
<soap:operation soapAction="urn:HelloWorldClassAction"/><input>
<soap:body namespace="urn:myTestWsdl" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input><output>
<soap:body namespace="urn:myTestWsdl" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding><service name="myTestWsdlService"><port name="HelloWorldClassPort" binding="typens:HelloWorldClassBinding">
<soap:address location="http://192.168.1.49/php2wsdl/HelloWorldClass.php"/>
</port>
</service>
</definitions>
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900