I am trying to develop a web service using WSDL, SOAP and PHP. I did a sample code and it seems to run well but the only problem is that it is giving me the following error messages:
Warning: SoapClient::SoapClient(
http://127.0.0.1/tutorial/inventory.wsdl ) [soapclient.soapclient]: failed to open stream: HTTP request failed! in C:\wamp\www\tutorial\clien
t-test.php
on line 3
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "
http://127.0.0.1/tutorial/inventory.wsdl " in C:\wamp\www\tutorial\clien
t-test.php
on line 3
Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\tutorial\clien
t-test.php
on line 6
Any help will be greatly appreciated
client-test.php
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$client = new SoapClient("http://127.0.0.1/tutorial/inventory.wsdl");
$return = $client->getItemCount('12345');
print_r($return);
?>
server.php
<?php
require 'inventory_functions.php';
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("c:/wamp/www/tutorial/inventory.wsdl");
$server->addFunction("getItemCount");
$server->handle();
?>
Inventory.wsdl
<?xml version='1.0' encoding='UTF-8' ?>
<definitions name='Inventory'
targetNamespace='urn:JimmyzInventory'
xmlns:tns='urn:JimmyzInventory'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='getItemCountRequest'>
<part name='upc' type='xsd:string'/>
</message>
<message name='getItemCountResponse'>
<part name='Result' type='xsd:integer'/>
</message>
<portType name='InventoryPortType'>
<operation name='getItemCount'>
<input message='tns:getItemCountRequest'/>
<output message='tns:getItemCountResponse'/>
</operation>
</portType>
<binding name='InventoryBinding' type='tns:InventoryPortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='getItemCount'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#getItemCount'/>
<input>
<soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<service name='InventoryService'>
<port name='InventoryPort' binding='InventoryBinding'>
<soap:address location='http://[path to glue code]/server.php'/>
</port>
</service>
</definitions>
inventory functions.php
<?php
function getItemCount($upc){
//in reality, this data would be coming from a database
$items = array('12345'=>5,'19283'=>100,'23489'=>'234');
return $items[$upc];
}
?>
Select all Open in new window