How PHP SOAP handle client request?
Moderator: General Moderators
How PHP SOAP handle client request?
It's my first time to touch the php SOAP. I have a wsdl file sits in my server. client send some request to the server (my side), then I'm gonna analyzes the data client sent to me, if it's correct, will put data into DB; otherwise I will send a response message back (all using SOAP format).
I've tried PHP Soap and NuSoap both, but just don't know how I can analyze the data that I received, then send message back.
Can you give me some tips? thank you!
I've tried PHP Soap and NuSoap both, but just don't know how I can analyze the data that I received, then send message back.
Can you give me some tips? thank you!
You might be interested in http://devzone.zend.com/node/view/id/689
feyd | Please use
client3.php
stockquote.wsdl
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[quote="volka"]You might be interested in http://devzone.zend.com/node/view/id/689[/quote]
yes, I tried it already. but when I run it in my localhost, it gave me the following error:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in C:\Program Files\xampp\htdocs\xml\stockquote\client3.php:3 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://localhos...', 'urn:xmethods-de...', 1, 0) #1 [internal function]: SoapClient->__call('getQuote', Array) #2 C:\Program Files\xampp\htdocs\xml\stockquote\client3.php(3): SoapClient->getQuote('ibm') #3 {main} thrown in C:\Program Files\xampp\htdocs\xml\stockquote\client3.php on line 3
server1.phpCode: Select all
$quotes = array("ibm"=>98.42);
function getQuote($symbol) {
global $quotes;
return $quotes[$symbol];
}
//ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("stockquote.wsdl");
$server->addFunction("getQuote");
$server->handle();client3.php
Code: Select all
$client = new SoapClient("stockquote.wsdl");
$client->getQuote("ibm");Code: Select all
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='StockQuote'
targetNamespace='http://localhost/xml/stockquote/StockQuote'
xmlns:tns='http://localhost/xml/stockquote/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://localhost/xml/stockquote/server1.php'/>
</port>
</service>
</definitions>
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]both server1.php and client3.php are sit on my local machine (localhost), as well as the WSDL file. the purpose of it to testing. in my client3.php, if i runvolka wrote:server1.php and client3.php are on the same computer and a webserver is running? It doesn't look that way.sunnyside wrote:Could not connect to host
Code: Select all
$client->__getFunctions()Code: Select all
Array ( [0] => float getQuote(string $symbol) )-
DariuzArkham
- Forum Newbie
- Posts: 1
- Joined: Wed May 02, 2007 8:04 am
sunnyside wrote:both server1.php and client3.php are sit on my local machine (localhost), as well as the WSDL file. the purpose of it to testing. in my client3.php, if i runvolka wrote:server1.php and client3.php are on the same computer and a webserver is running? It doesn't look that way.sunnyside wrote:Could not connect to host, I have no problem to get theCode: Select all
$client->__getFunctions()result.Code: Select all
Array ( [0] => float getQuote(string $symbol) )
I've had this exact problem myself.
When I changed "localhost" to "127.0.0.1" in the .wsdl file it worked.