Jump to content

PHP-Soap problem


adyy

Recommended Posts

Hello all,

 

I played these days with the SOAP extension of the PHP.

I started from this tutorial:

http://devzone.zend.com/node/view/id/689

 

Then I modified a bit the code for my own needs, but . . . there is one problem. From the SOAP client I'm sending via a registered function 2 (two) parameters and I'm receiving at the server only one, the first.

 

Is there any limitation in the PHP-SOAP for this? Or did I done some big mistake here?

 

Here is the fillter.wsdl file:

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?><wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test.adyy.org/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="fillter" targetNamespace="http://test.adyy.org/soap/">  <wsdl:types>    <xsd:schema targetNamespace="http://localhost/soap/">            <xsd:element name="getFilltered" type="tns:getFilltered">      </xsd:element>      <xsd:element name="getFillteredResponse" type="tns:getFillteredResponse">      </xsd:element>      <xsd:complexType name="getFilltered">        <xsd:sequence>            <xsd:element name="text" type="xsd:string"></xsd:element>            <xsd:element name="key" type="xsd:string"></xsd:element>        </xsd:sequence>      </xsd:complexType>          <xsd:complexType name="getFillteredResponse">        <xsd:sequence>            <xsd:element name="result" type="xsd:string"></xsd:element>        </xsd:sequence>      </xsd:complexType>    </xsd:schema>  </wsdl:types>    <wsdl:message name="getFillteredRequest">    <wsdl:part element="tns:getFilltered" name="parameters"/>  </wsdl:message>    <wsdl:message name="getFillteredResponse">    <wsdl:part element="tns:getFillteredResponse" name="parameters"/>  </wsdl:message>    <wsdl:portType name="fillter">    <wsdl:operation name="getFilltered">      <wsdl:input message="tns:getFillteredRequest"/>      <wsdl:output message="tns:getFillteredResponse"/>    </wsdl:operation>  </wsdl:portType>    <wsdl:binding name="fillterSOAP" type="tns:fillter">    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>    <wsdl:operation name="getFilltered">      <soap:operation soapAction=""/>      <wsdl:input>        <soap:body use="literal"/>      </wsdl:input>      <wsdl:output>        <soap:body use="literal"/>      </wsdl:output>    </wsdl:operation>  </wsdl:binding>    <wsdl:service name="fillter">    <wsdl:port binding="tns:fillterSOAP" name="fillterSOAP">      <soap:address location="http://localhost/soap/server.php"/>    </wsdl:port>  </wsdl:service>  </wsdl:definitions>

 

Here is the server code:

 

<?phpfunction getFilltered($text, $key) {    $result = $text.$key;  return $result;}ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache $server = new SoapServer("fillter.wsdl"); $server->addFunction("getFilltered"); $server->handle();?>

 

Here is the client file:

 

<?php$mall_text = $_POST[s1];$text        = $_POST[s2];if(!$mall_text){  $mall_text = "text";}if(!$text){  $text = "text";}$key = $mall_text;////// client SOAP //////      $client = new SoapClient("fillter.wsdl", array('trace' => 1));  $filter_result = $client->getFilltered($text, $key);  ////// client SOAP end  //////// scrie timestamp dupa ce textul a fost procesat$log_string = $log_string.getmicrotime()." --- "."Text a fost procesat. Finish!!!<br>";?><body><center><table border="0" bgcolor="#CCCCFF" cellpadding="12" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="80%" height="400">  <tr>    <td width="40%" height="277" valign="top">    <!-- form for sending text to be filtered -->    <form method="post" action="<?php print $_SERVER['PHP_SELF']; ?>">      Cuvinte interzise:<br>      <textarea rows="12" name="S1" cols="50"><?php print $mall_text; ?></textarea><br><br>      Text ce trebuie filtrat:<br>      <textarea rows="15" name="S2" cols="50"><?php print $text; ?></textarea><br>      <input type="submit" value="Fillter" name="B1">    </form>    <!-- form is finished -->    </td>    <td width="40%" height="277" valign="top">    <!-- tabel in care se pun datele filtrate -->    Text filtrat:<br>    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-style: dotted" bordercolor="#808080" bgcolor="#FFFFFF" width="100%" height="350">      <tr>        <td valign="top">        <?php echo $filter_result; ?>        </td>      </tr>    </table>    <!-- sfarsit tabel in care se pun datele filtrate -->    </td>  </tr></table></center><?php echo "Log data:<br>";echo $log_string;echo "<br>REQUEST: " . $client->__getLastRequest() . "<br>";echo "RESPONSE: " . $client->__getLastResponse() . "<br>";?>

 

Also I have tomention that I'm working with the XAMPP-Lite 1.6.6 server.[/]

Link to comment
https://forums.phpfreaks.com/topic/129126-php-soap-problem/
Share on other sites

CroNiX, thanks for the hint !

here, again, are the files I created for the SOAP Service.

 

WSDL file:

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test.adyy.org/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="fillter" targetNamespace="http://test.adyy.org/soap/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://localhost/soap/">
      
      <xsd:element name="getFilltered" type="tns:getFilltered">
      </xsd:element>
      <xsd:element name="getFillteredResponse" type="tns:getFillteredResponse">
      </xsd:element>

      <xsd:complexType name="getFilltered">
      	<xsd:sequence>
      		<xsd:element name="text" type="xsd:string"></xsd:element>
      		<xsd:element name="key" type="xsd:string"></xsd:element>
      	</xsd:sequence>
      </xsd:complexType>
    
      <xsd:complexType name="getFillteredResponse">
      	<xsd:sequence>
      		<xsd:element name="result" type="xsd:string"></xsd:element>
      	</xsd:sequence>
      </xsd:complexType>
    </xsd:schema>
  </wsdl:types>
  
  <wsdl:message name="getFillteredRequest">
    <wsdl:part element="tns:getFilltered" name="parameters"/>
  </wsdl:message>
  
  <wsdl:message name="getFillteredResponse">
    <wsdl:part element="tns:getFillteredResponse" name="parameters"/>
  </wsdl:message>
  
  <wsdl:portType name="fillter">
    <wsdl:operation name="getFilltered">
      <wsdl:input message="tns:getFillteredRequest"/>
      <wsdl:output message="tns:getFillteredResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  
  <wsdl:binding name="fillterSOAP" type="tns:fillter">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getFilltered">
      <soap:operation soapAction=""/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  
  <wsdl:service name="fillter">
    <wsdl:port binding="tns:fillterSOAP" name="fillterSOAP">
      <soap:address location="http://localhost/soap/server.php"/>
    </wsdl:port>
  </wsdl:service>
  
</wsdl:definitions>

 

server

 

<?php
function getFilltered($text, $key) 
{	
  	$result = $text.$key;
return $result;
}

ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache 
$server = new SoapServer("fillter.wsdl"); 
$server->addFunction("getFilltered"); 
$server->handle();
?>

 

client

 

<?php

$mall_text = $_POST[s1];
$text        = $_POST[s2];

if(!$mall_text){
$mall_text = "text";
}

if(!$text){
$text = "text";
}

$key = $mall_text;

////// client SOAP //////

$client = new SoapClient("fillter.wsdl", array('trace' => 1));
$filter_result = $client->getFilltered($text, $key);

////// client SOAP end  //////
?>

<body>

<center>
<table border="0" bgcolor="#CCCCFF" cellpadding="12" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="80%" height="400">
  <tr>
    <td width="40%" height="277" valign="top">
    <!-- form for sending text to be filtered -->
    <form method="post" action="<?php print $_SERVER['PHP_SELF']; ?>">
      Cuvinte interzise:<br>
      <textarea rows="12" name="S1" cols="50"><?php print $mall_text; ?></textarea><br><br>
      Text ce trebuie filtrat:<br>
      <textarea rows="15" name="S2" cols="50"><?php print $text; ?></textarea><br>
      <input type="submit" value="Fillter" name="B1">
    </form>
    <!-- form is finished -->
    </td>
    <td width="40%" height="277" valign="top">
    <!-- tabel in care se pun datele filtrate -->
    Text filtrat:<br>
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-style: dotted" bordercolor="#808080" bgcolor="#FFFFFF" width="100%" height="350">
      <tr>
        <td valign="top">
        <?php echo $filter_result; ?>
        </td>
      </tr>
    </table>
    <!-- sfarsit tabel in care se pun datele filtrate -->
    </td>
  </tr>
</table>
</center>

<?php 
echo "Log data:<br>";
echo $log_string;

echo "<br>REQUEST: " . $client->__getLastRequest() . "<br>";
echo "RESPONSE: " . $client->__getLastResponse() . "<br>";

?>

Link to comment
https://forums.phpfreaks.com/topic/129126-php-soap-problem/#findComment-669474
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.