RE: [PHP] Need a working SOAP example using SOAP -- PHP is blocking the calls (scripts)
| From: | Daevid Vincent | Date: | Mon, 09 Apr 2007 19:32:42 +0000 |
| Subject: | RE: [PHP] Need a working SOAP example using SOAP -- PHP is blocking the calls (scripts) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252354@lists.php.net to get a copy of this message | ||
Here is the code I'm using:
client1.php
<?php
$client = new
SoapClient("http://machine.locutus.com/StockQuote/stockquote.wsdl",
# $client = new
SoapClient("https://admin:testing@172.16.0.111/stockquote.wsdl",
array(
# "login" => "admin",
# "password" => "testing",
"trace" => 1,
"exceptions" => 0));
print($client->getQuote("ibm"));
?>
server1.php
<?php
// http://devzone.zend.com/node/view/id/689
$quotes = array( "ibm" => 98.42 );
function getQuote($symbol) {
global $quotes;
return $quotes[$symbol];
}
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
//exit( "foo");
$server = new SoapServer("stockquote.wsdl");
$server->addFunction("getQuote");
$server->handle();
?>
stockquote.wsdl
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='StockQuote'
targetNamespace='http://example.org/StockQuote'
xmlns:tns='http://example.org/StockQuote'
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='getQuoteRequest'>
<part name='symbol' type='xsd:string'/>
</message>
<message name='getQuoteResponse'>
<part name='Result' type='xsd:float'/>
</message>
<portType name='StockQuotePortType'>
<operation name='getQuote'>
<input message='tns:getQuoteRequest'/>
<output message='tns:getQuoteResponse'/>
</operation>
</portType>
<binding name='StockQuoteBinding' type='tns:StockQuotePortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='getQuote'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#getQuote'/>
<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='StockQuoteService'>
<port name='StockQuotePort' binding='tns:StockQuoteBinding'>
<soap:address
location='http://machine.locutus.com/StockQuote/server1.php'/>
</port>
</service>
</definitions>