S
S
Sarvar Abduhakimov2015-09-14 15:35:15
PHP
Sarvar Abduhakimov, 2015-09-14 15:35:15

How to send WSDL to client two parameters as a response via server WSDL?

You need to send the WSDL client two parameters Result and Comments as a response through the WSDL server
WSDL file stockquote1.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="Data" type="xs:string"/>
 <part name="Signature" type="xs:string"/>
 <part name="PublicCert" type="xs:string"/>
 <part name="SignDate" type="xs:dateTime"/> 
</message> 

<message name='getQuoteResponse'> 
<part name='Result' type='xsd:float'/>
<part name="Comments" type="xs:string"/> 
</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='StockQuoteBinding'> 
  <soap:address location='http://localhost/wsdl1/server1.php'/> 
 </port> 
</service> 
</definitions>

Server1.php:
global $quotes1; 
class QuoteService {  
  private $quotes1 = array("ok" => 1, 'error'=>0);    

  function getQuote($Data, $Signature, $PublicCert, $SignDate) {
   global $quotes1;
    if (isset($Data)) {

  return $quotes1['ok']; 
    } 
  }  
}  

$server = new SoapServer("stockquote1.wsdl",array(  
    "exceptions" => 1,
  'style' => SOAP_DOCUMENT,
  'use' => SOAP_LITERAL,
  'soap_version' => SOAP_1_2,
  'encoding' => 'UTF-8'
  ));  
$server->setClass("QuoteService");  
$server->handle();

Client1.php:
$ibm = array('Data'=>array('adress'=>'Tashkent', 'house'=>74), 'Signature'=>'Signature', 'PublicCert'=>'PublicCert', 'SignDate'=>date('d-m-Y'));
  $client = new SoapClient("stockquote1.wsdl",array(  
    "trace"      => 1,  
    "exceptions" => 1,
  'style' => SOAP_DOCUMENT,
  'use' => SOAP_LITERAL,
  'soap_version' => SOAP_1_2,
  'encoding' => 'UTF-8'
  )
    );   

    print($client->__call('getQuote', $ibm)); 

print "<pre>\n";  
  print "Запрос :\n".htmlspecialchars($client->__getLastRequest()) ."\n";  
  print "Ответ:\n".htmlspecialchars($client->__getLastResponse())."\n";  
  print "</pre>";

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sarvar Abduhakimov, 2015-09-15
@Sarvar4ik

Here I found the
server1.php answer:

global $quotes1; 
class QuoteService {  
  private $quotes1 = array("ok" => 1, 'error'=>0);    

  function getQuote($Data, $Signature, $PublicCert, $SignDate) {
   global $quotes1;
    if (isset($Data)) {

  return array('Result' => 1, 'Comments' => 'Все данные успешно получены!'); 
    } 
  }  
}  

$server = new SoapServer("stockquote1.wsdl",array(  
    "exceptions" => 1,
  'style' => SOAP_DOCUMENT,
  'use' => SOAP_LITERAL,
  'soap_version' => SOAP_1_2,
  'encoding' => 'UTF-8'
  ));  
$server->setClass("QuoteService");  
$server->handle();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question