Advertisement
Guest User

Untitled

a guest
Feb 5th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. my wsdl file (catalog.wsdl):
  2. <?xml version ='1.0' encoding ='UTF-8' ?>
  3. <definitions name='Catalog'
  4. targetNamespace='http://localhost/catalog.wsdl'
  5. xmlns:tns='http://localhost/catalog.wsdl'
  6. xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
  7. xmlns:xsd='http://www.w3.org/2001/XMLSchema'
  8. xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
  9. xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
  10. xmlns='http://schemas.xmlsoap.org/wsdl/'>
  11.  
  12. <message name='getCatalogRequest'>
  13. <part name='catalogId' type='xsd:string'/>
  14. </message>
  15. <message name='getCatalogResponse'>
  16. <part name='Result' type='xsd:string'/>
  17. </message>
  18.  
  19. <portType name='CatalogPortType'>
  20. <operation name='getCatalogEntry'>
  21. <input message='tns:getCatalogRequest'/>
  22. <output message='tns:getCatalogResponse'/>
  23. </operation>
  24. </portType>
  25.  
  26. <binding name='CatalogBinding' type='tns:CatalogPortType'>
  27. <soap:binding style='rpc'
  28. transport='http://schemas.xmlsoap.org/soap/http'/>
  29. <operation name='getCatalogEntry'>
  30. <soap:operation soapAction='urn:localhost-catalog#getCatalogEntry'/>
  31. <input>
  32. <soap:body use='encoded' namespace='urn:localhost-catalog'
  33. encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  34. </input>
  35. <output>
  36. <soap:body use='encoded' namespace='urn:localhost-catalog'
  37. encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  38. </output>
  39. </operation>
  40. </binding>
  41.  
  42. <service name='CatalogService'>
  43. <port name='CatalogPort' binding='CatalogBinding'>
  44. <soap:address location='http://localhost/soap-server.php'/>
  45. </port>
  46. </service>
  47. </definitions>
  48.  
  49. my soap-server.php file :
  50. <?php
  51. function getCatalogEntry($catalogId)
  52. {
  53. if ($catalogId == 'catalog1')
  54. {
  55. $first = "n";
  56. return $first;
  57. }
  58. elseif ($catalogId == 'catalog2')
  59. {
  60. $second = "m";
  61. return $second;
  62. }
  63. }
  64. ini_set("soap.wsdl_cache_enabled", "0");
  65. $server = new SoapServer("http://localhost/catalog.wsdl");
  66. $server->addfunction("getCatalogEntry");
  67. $server->handle();
  68. ?>
  69.  
  70.  
  71. my soap-client.php file:
  72.  
  73. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  74. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  75. <head>
  76. <title>simple SOAP test</title>
  77. <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  78. </head>
  79. <body>
  80.  
  81. <?php
  82.  
  83. try {
  84. echo "m";
  85. $client = new SoapClient('http://localhost/catalog.wsdl');
  86. $catalogId = 'catalog1';
  87. $response = $client->getCatalogEntry($catalogId);
  88.  
  89.  
  90. } catch (SoapFault $fault) {
  91.  
  92. echo "Error :".$fault->getMessage();
  93.  
  94.  
  95. }
  96.  
  97. echo $response;
  98. var_dump(var_dump);
  99. ?>
  100.  
  101. </body>
  102. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement