Avatar of kiptieu
kiptieu
 asked on

Php-soap Related Problem

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\client-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\client-test.php on line 3

Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\tutorial\client-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];
}
?>

Open in new window

Windows NetworkingPHP

Avatar of undefined
Last Comment
MikeKane

8/22/2022 - Mon
MikeKane

I think you may have posted this in the wrong section.   This doesn't really look like a NT OS issue but rather a programming debug.  
ASKER CERTIFIED SOLUTION
MikeKane

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck