Я пытаюсь создать веб-сервис, используя стиль документа и использование буквального переноса, но это не работает, я всегда получаю результат с пустым значением, это проблема с Nu SOAP?
Документ WSDL: Стиль документа Использование Literal Wrapped
<?xml version="1.0" encoding="UTF-8" ?>
<!--
class EtudiantClass {
function etudiant($array_etudiant_module_informations) {
...
return $array_note('note_module' => $note);
}
}
-->
<definitions name="etudiant"
targetNamespace="http://localhost:80/Etudiant"
xmlns:tns="http://localhost:80/Etudiant"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<types>
<xsd:schema targetNamespace="http://localhost:80/Etudiant">
<xsd:element name="EtudiantClass.etudiant">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="nom" type="xsd:string" />
<xsd:element name="prenom" type="xsd:string" />
<xsd:element name="matricule" type="xsd:string" />
<xsd:element name="nom_module" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="EtudiantClass.etudiantResponse">
<xsd:complexType>
<xsd:all>
<xsd:element name="note_module" type="xsd:float" />
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="etudiant_module_informations">
<part name="etudiant_module_infos" element="tns:EtudiantClass.etudiant" />
</message>
<message name="note_module">
<part name="note" element="tns:EtudiantClass.etudiantResponse" />
</message>
<portType name="etudiant_portType">
<operation name="EtudiantClass.etudiant">
<input message="tns:etudiant_module_informations" />
<output message="tns:note_module" />
</operation>
</portType>
<binding name="etudiant_binding" type="tns:etudiant_portType">
<operation name="EtudiantClass.etudiant">
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<soap:operation soapAction="http://localhost:80/Etudiant#etudiant" />
</operation>
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
</binding>
<service name="etudiant_service">
<port name="etudiant_port" binding="tns:etudiant_binding">
<soap:address location="http://localhost:80/Etudiant/WebService.php" />
</port>
</service>
</definitions>
Веб-служба PHP
<?php
require_once("lib/nusoap.php");
class EtudiantClass {
function etudiant($array_etudiant_module_informations)
{
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "etudiantdb";
$connection = mysqli_connect($servername,$username,$password);
if (!$connection) {
die("Connection failed: " . mysqli_connect_error());
}
mysqli_select_db($connection, $dbname);
$NOM = $array_etudiant_module_informations['nom'];
$PRENOM = $array_etudiant_module_informations['prenom'];
$MATRICULE = $array_etudiant_module_informations['matricule'];
$MODULE = $array_etudiant_module_informations['nom_module'];
$sql_request = "SELECT NOTE FROM etudiant WHERE NOM = '".$NOM."' AND PRENOM = '".$PRENOM."' AND MATRICULE = '".$MATRICULE."' AND MODULE = '".$MODULE."'";
$result = mysqli_query($connection, $sql_request);
$row = mysqli_fetch_assoc($result);
mysqli_close($connection);
$array_result = array('note_module' => $row['NOTE']);
return $array_result;
}
}
$server = new soap_server();
$server -> configureWSDL('Etudiant','http://localhost:80/Etudiant');
$server->wsdl->addComplexType(
'type_etudiant_module',
'complexType',
'struct',
'sequence',
'',
array('nom' => array('name'=>'nom','type'=>'xsd:string'),
'prenom' => array('name'=>'prenom','type'=>'xsd:string'),
'matricule' => array('name'=>'matricule','type'=>'xsd:string'),
'nom_module' => array('name'=>'nom_module','type'=>'xsd:string')
)
);
$server->wsdl->addComplexType(
'type_note_module',
'complexType',
'struct',
'all',
'',
array('note_module' => array('name'=>'note_module','type'=>'xsd:float')
)
);
$server->register('EtudiantClass.etudiant',
array('etudiant_module_infos' => 'tns:type_etudiant_module'),
array('note' => 'tns:type_note_module'),
'http://localhost:80/Etudiant',
'http://localhost:80/Etudiant#etudiant',
'document',
'literal',
'La note d\'un étudiant dans un module donné'
);
@$server->service(file_get_contents("php://input"));
?>
SOAP Запрос
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:etud="http://localhost:80/Etudiant">
<soapenv:Header/>
<soapenv:Body>
<etud:EtudiantClass.etudiant>
<nom>TCHERAK</nom>
<prenom>Amine</prenom>
<matricule>M1531081239</matricule>
<nom_module>VLSI</nom_module>
</etud:EtudiantClass.etudiant>
</soapenv:Body>
</soapenv:Envelope>
SOAP Ответ (Проблема Пустое значение)
<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/">
<SOAP-ENV:Body>
<EtudiantClass.etudiantResponse xmlns="http://localhost:80/Etudiant">
<note xmlns=""/>
</EtudiantClass.etudiantResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>