Witam, mam problem, moja usługa zwraca mi cos takiego:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  3. <SOAP-ENV:Body>
  4. <TestResponse xmlns="namespace">
  5. <TestResult xmlns="">
  6. <Sukces>true</Sukces>
  7. <OpisBledu></OpisBledu>
  8. </TestResult>
  9. </TestResponse>
  10. </SOAP-ENV:Body>
  11. </SOAP-ENV:Envelope>


A potrzebuje, żeby zwróciła dokładnie coś takiego:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  3. <soap:Body>
  4. <TestResponse xmlns="namespace">
  5. <TestResult>
  6. <Sukces>true</Sukces>
  7. <OpisBledu />
  8. </TestResult>
  9. </TestResponse>
  10. </soap:Body>
  11. </soap:Envelope>



Dwie różnice, które wydaje mi się trzeby poprawić to:

Tego nie powinno być
  1. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"


A to powinno byc bez atrybutu xmlns=""
  1. <TestResult xmlns="">



Mój kod to:

  1. <?php
  2. require 'lib/nusoap.php';
  3.  
  4. $namespace = "namespace";
  5.  
  6. $server = new nusoap_server();
  7. $server->debug_flag = false;
  8. $server->configureWSDL("nuSoapWSDL", $namespace);
  9. $server->wsdl->schemaTargetNamespace = $namespace;
  10.  
  11. # TEST
  12. $server->wsdl->addComplexType(
  13. 'OdpowiedzTest',
  14. 'complexType',
  15. 'struct',
  16. 'all',
  17. '',
  18. 'Sukces' => array('name' => 'Sukces', 'type' => 'xsd:boolean'),
  19. 'OpisBledu' => array('name' => 'OpisBledu', 'type' => 'xsd:string')
  20. )
  21. );
  22.  
  23. $server->wsdl->addComplexType(
  24. 'TestResult',
  25. 'complexType',
  26. 'struct',
  27. 'all',
  28. '',
  29. 'TestResult' => array('name' => 'TestResult', 'type' => 'tns:OdpowiedzTest')
  30. )
  31. );
  32.  
  33. $server->register('Test', // method name
  34. array('Login' => 'xsd:string', 'Haslo' => 'xsd:string', 'Filia' => 'xsd:string'), // input parameters
  35. array('TestResult' => 'tns:OdpowiedzTest'), // output parameters
  36. $namespace, // namespace
  37. $namespace . 'Test', // soapaction
  38. 'document', // style rpc or document
  39. 'literal', // use literal od encoded
  40. 'Sprawdza autoryzację połączenia' // documentation
  41. );
  42.  
  43. function Test($Login, $Haslo, $Filia)
  44. {
  45. if($Login == "TEST" AND $Haslo == "TEST")
  46. {
  47. $sukcess = true;
  48. $opisbledu = "";
  49. }
  50. else{
  51. $sukcess = false;
  52. $opisbledu = "Błąd autoryzacji.";
  53. }
  54.  
  55. $test['TestResult'] = [];
  56. $test['TestResult']['Sukces'] = $sukcess;
  57. $test['TestResult']['OpisBledu'] = $opisbledu;
  58.  
  59. return $test;
  60. }
  61.  
  62. $postdata = file_get_contents("php://input");
  63. $postdata = isset($postdata) ? $postdata : '';
  64.  
  65. $server->service($postdata);



Z góry bardzo dziękuje za pomoc, walcz już z tym naprawde długo wink.gif