Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my wsdl file (catalog.wsdl):
- <?xml version ='1.0' encoding ='UTF-8' ?>
- <definitions name='Catalog'
- targetNamespace='http://localhost/catalog.wsdl'
- xmlns:tns='http://localhost/catalog.wsdl'
- 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='getCatalogRequest'>
- <part name='catalogId' type='xsd:string'/>
- </message>
- <message name='getCatalogResponse'>
- <part name='Result' type='xsd:string'/>
- </message>
- <portType name='CatalogPortType'>
- <operation name='getCatalogEntry'>
- <input message='tns:getCatalogRequest'/>
- <output message='tns:getCatalogResponse'/>
- </operation>
- </portType>
- <binding name='CatalogBinding' type='tns:CatalogPortType'>
- <soap:binding style='rpc'
- transport='http://schemas.xmlsoap.org/soap/http'/>
- <operation name='getCatalogEntry'>
- <soap:operation soapAction='urn:localhost-catalog#getCatalogEntry'/>
- <input>
- <soap:body use='encoded' namespace='urn:localhost-catalog'
- encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
- </input>
- <output>
- <soap:body use='encoded' namespace='urn:localhost-catalog'
- encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
- </output>
- </operation>
- </binding>
- <service name='CatalogService'>
- <port name='CatalogPort' binding='CatalogBinding'>
- <soap:address location='http://localhost/soap-server.php'/>
- </port>
- </service>
- </definitions>
- my soap-server.php file :
- <?php
- function getCatalogEntry($catalogId)
- {
- if ($catalogId == 'catalog1')
- {
- $first = "n";
- return $first;
- }
- elseif ($catalogId == 'catalog2')
- {
- $second = "m";
- return $second;
- }
- }
- ini_set("soap.wsdl_cache_enabled", "0");
- $server = new SoapServer("http://localhost/catalog.wsdl");
- $server->addfunction("getCatalogEntry");
- $server->handle();
- ?>
- my soap-client.php file:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>simple SOAP test</title>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
- </head>
- <body>
- <?php
- try {
- echo "m";
- $client = new SoapClient('http://localhost/catalog.wsdl');
- $catalogId = 'catalog1';
- $response = $client->getCatalogEntry($catalogId);
- } catch (SoapFault $fault) {
- echo "Error :".$fault->getMessage();
- }
- echo $response;
- var_dump(var_dump);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement