<p>Is there available any tool for PHP which can be used to generate code for consuming a <a href="http://en.wikipedia.org/wiki/Web_service" rel="noreferrer">web service</a> based on its <a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language" rel="noreferrer">WSDL</a>? Something comparable to clicking "Add Web Reference" in Visual Studio or the Eclipse plugin which does the same thing for Java.</p>

[{'answer_id': 4491, 'author': 'Vaibhav', 'author_id': 380, 'author_profile': 'https://Stackoverflow.com/users/380', 'pm_score': 1, 'selected': False, 'text': '<p>Well, those features are specific to a tool that you are using for development in those languages.</p>\n\n<p>You wouldn\'t have those tools if (for example) you were using notepad to write code. So, maybe you should ask the question for the tool you are using.</p>\n\n<p>For PHP: <a href="http://webservices.xml.com/pub/a/ws/2004/03/24/phpws.html" rel="nofollow noreferrer">http://webservices.xml.com/pub/a/ws/2004/03/24/phpws.html</a></p>\n'}, {'answer_id': 9840, 'author': 'Wally Lawless', 'author_id': 37, 'author_profile': 'https://Stackoverflow.com/users/37', 'pm_score': 3, 'selected': False, 'text': '<p>I have used <a href="https://sourceforge.net/projects/nusoap/" rel="nofollow noreferrer">NuSOAP</a> in the past.  I liked it because it is just a set of PHP files that you can include.  There is nothing to install on the web server and no config options to change.  It has WSDL support as well which is a bonus.</p>\n'}, {'answer_id': 12585, 'author': 'pix0r', 'author_id': 72, 'author_profile': 'https://Stackoverflow.com/users/72', 'pm_score': 5, 'selected': True, 'text': '<p>I\'ve had great success with <a href="https://github.com/jbarciauskas/wsdl2php" rel="noreferrer">wsdl2php</a>.  It will automatically create wrapper classes for all objects and methods used in your web service.</p>\n'}, {'answer_id': 24490, 'author': 'davidmytton', 'author_id': 2183, 'author_profile': 'https://Stackoverflow.com/users/2183', 'pm_score': 6, 'selected': False, 'text': '<p>In PHP 5 you can use <a href="http://www.php.net/manual/en/ref.soap.php" rel="noreferrer">SoapClient</a> on the WSDL to call the web service functions. <a href="http://www.php.net/manual/en/soapclient.construct.php" rel="noreferrer">For example</a>:</p>\n\n<pre><code>$client = new SoapClient("some.wsdl");\n</code></pre>\n\n<p>and $client is now an object which has class methods as defined in some.wsdl. So if there was a method called getTime in the WSDL then you would just call:</p>\n\n<pre><code>$result = $client-&gt;getTime();\n</code></pre>\n\n<p>And the result of that would (obviously) be in the $result variable. You can use the __getFunctions method to return a list of all the available methods.</p>\n'}, {'answer_id': 6827835, 'author': 'Hoan', 'author_id': 863104, 'author_profile': 'https://Stackoverflow.com/users/863104', 'pm_score': 2, 'selected': False, 'text': '<p>This <a href="http://4rapiddev.com/php/call-web-service-wsdl-example/" rel="nofollow">article</a> explains how you can use PHP SoapClient to call a api web service.</p>\n'}, {'answer_id': 32475441, 'author': 'Mashudu Muleya', 'author_id': 5316309, 'author_profile': 'https://Stackoverflow.com/users/5316309', 'pm_score': 1, 'selected': False, 'text': '<p>HI I got this from this site : <a href="http://forums.asp.net/t/887892.aspx?Consume+an+ASP+NET+Web+Service+with+PHP" rel="nofollow">http://forums.asp.net/t/887892.aspx?Consume+an+ASP+NET+Web+Service+with+PHP</a></p>\n\n<p>The web service has method <code>Add</code> which takes two params:</p>\n\n<pre><code>&lt;?php\n    $client = new SoapClient("http://localhost/csharp/web_service.asmx?wsdl");\n\n     print_r( $client-&gt;Add(array("a" =&gt; "5", "b" =&gt;"2")));\n?&gt;\n</code></pre>\n'}, {'answer_id': 37068486, 'author': 'Luke Wenke', 'author_id': 785309, 'author_profile': 'https://Stackoverflow.com/users/785309', 'pm_score': 2, 'selected': False, 'text': '<p>Say you were provided the following:</p>\n\n<pre><code>&lt;x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://thesite.com/"&gt;\n    &lt;x:Header/&gt;\n    &lt;x:Body&gt;\n        &lt;int:authenticateLogin&gt;\n            &lt;int:LoginId&gt;12345&lt;/int:LoginId&gt;\n        &lt;/int:authenticateLogin&gt;\n    &lt;/x:Body&gt;\n&lt;/x:Envelope&gt;\n</code></pre>\n\n<p>and</p>\n\n<pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;\n    &lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;\n        &lt;authenticateLoginResponse xmlns="http://thesite.com/"&gt;\n            &lt;authenticateLoginResult&gt;\n                &lt;RequestStatus&gt;true&lt;/RequestStatus&gt;\n                &lt;UserName&gt;003p0000006XKX3AAO&lt;/UserName&gt;\n                &lt;BearerToken&gt;Abcdef1234567890&lt;/BearerToken&gt;\n            &lt;/authenticateLoginResult&gt;\n        &lt;/authenticateLoginResponse&gt;\n    &lt;/s:Body&gt;\n&lt;/s:Envelope&gt;\n</code></pre>\n\n<p>Let\'s say that accessing <a href="http://thesite.com/" rel="nofollow">http://thesite.com/</a> said that the WSDL address is:\n<a href="http://thesite.com/PortalIntegratorService.svc?wsdl" rel="nofollow">http://thesite.com/PortalIntegratorService.svc?wsdl</a></p>\n\n<pre><code>$client = new SoapClient(\'http://thesite.com/PortalIntegratorService.svc?wsdl\');\n$result = $client-&gt;authenticateLogin(array(\'LoginId\' =&gt; 12345));\nif (!empty($result-&gt;authenticateLoginResult-&gt;RequestStatus)\n    &amp;&amp; !empty($result-&gt;authenticateLoginResult-&gt;UserName)) {\n    echo \'The username is: \'.$result-&gt;authenticateLoginResult-&gt;UserName;\n}\n</code></pre>\n\n<p>As you can see, the items specified in the XML are used in the PHP code though the LoginId value can be changed.</p>\n'}]
['https://Stackoverflow.com/questions/4430', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/349/']