Skip to content
Snippets Groups Projects
Commit a7fe8197 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Module StepStar : possibilité de configurer les noms des opérations de l'API

parent bcafd346
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="http://www.abes.fr/DepotTEF/" xsi:schemaLocation="http://schemas.xmlsoap.org/wsdl/ http://schemas.xmlsoap.org/wsdl/2003-02-11.xsd" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.abes.fr/DepotTEF/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<types>
<xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.abes.fr/DepotTEF/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<xsd:import namespace="http://www.w3.org/2005/05/xmlmime" schemaLocation="DepotTEF?xsd=xmime.xsd"/>
<xsd:complexType name="Depot">
<xsd:sequence>
<xsd:element minOccurs="0" name="idEtablissement" type="xsd:string"/>
<xsd:element minOccurs="0" name="tef" type="xmime:base64Binary"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DepotAvecZip">
<xsd:sequence>
<xsd:element minOccurs="0" name="idEtablissement" type="xsd:string"/>
<xsd:element minOccurs="0" name="tef" type="xmime:base64Binary"/>
<xsd:element minOccurs="0" name="zip" type="xmime:base64Binary"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="DepotRequest" type="tns:Depot"/>
<xsd:element name="DepotRequestAvecZip" type="tns:DepotAvecZip"/>
<xsd:element name="DepotResponse" type="xsd:string"/>
</xsd:schema>
</types>
<message name="DepotRequestAvecZip">
<part name="part1" element="tns:DepotRequestAvecZip">
</part>
</message>
<message name="DepotResponse">
<part name="part1" element="tns:DepotResponse">
</part>
</message>
<message name="DepotRequest">
<part name="part1" element="tns:DepotRequest">
</part>
</message>
<portType name="DepotTEFPortType">
<operation name="deposer">
<input message="tns:DepotRequest" wsaw:Action="deposer">
</input>
<output message="tns:DepotResponse" wsaw:Action="http://schemas.xmlsoap.org/wsdl/DepotTEFPortType/tns:DepotResponse">
</output>
</operation>
<operation name="deposerAvecZip">
<input message="tns:DepotRequestAvecZip" wsaw:Action="deposerAvecZip">
</input>
<output message="tns:DepotResponse" wsaw:Action="http://schemas.xmlsoap.org/wsdl/DepotTEFPortType/tns:DepotResponse">
</output>
</operation>
</portType>
<binding name="DepotTEFSOAPBinding" type="tns:DepotTEFPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="deposer">
<soap:operation soapAction="http://www.abes.fr/DepotTEF/deposer"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="deposerAvecZip">
<soap:operation soapAction="http://www.abes.fr/DepotTEF/deposerAvecZip"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="DepotTEF">
<port name="DepotTEFSOAPport_http" binding="tns:DepotTEFSOAPBinding">
<soap:address location="https://imports-test.theses.fr/services/DepotTEF"/>
</port>
</service>
</definitions>
...@@ -91,8 +91,7 @@ return [ ...@@ -91,8 +91,7 @@ return [
'api' => [ 'api' => [
'soap_client' => [ 'soap_client' => [
'wsdl' => [ 'wsdl' => [
// 'url' => 'https://imports-test.theses.fr/services/DepotTEF.wsdl', 'url' => 'https://xxxx/yyyyy.wsdl',
//// 'url' => 'https://imports-new-test.theses.fr/ThesesImports/services/DepotTEF.wsdl',
], ],
'soap' => [ 'soap' => [
'version' => SOAP_1_1, // cf. extension "php-soap" 'version' => SOAP_1_1, // cf. extension "php-soap"
...@@ -100,10 +99,14 @@ return [ ...@@ -100,10 +99,14 @@ return [
//'proxy_port' => 3128, //'proxy_port' => 3128,
], ],
], ],
'operations' => [
// 'deposer' => 'deposer',
// 'deposer_avec_zip' => 'deposerAvecZip',
'deposer' => 'Depot',
'deposer_avec_zip' => 'DepotAvecZip',
],
'params' => [ 'params' => [
// 'idEtablissement' => 'SYGA', 'idEtablissement' => 'XXXX',
'idEtablissement' => 'NORM',
// 'ws' => 'ABES_TRF_THESE',
], ],
], ],
'notification' => [ 'notification' => [
......
...@@ -13,19 +13,16 @@ return [ ...@@ -13,19 +13,16 @@ return [
'api' => [ 'api' => [
'soap_client' => [ 'soap_client' => [
'wsdl' => [ 'wsdl' => [
'url' => 'https://imports-test.theses.fr/services/DepotTEF.wsdl', 'url' => 'https://xxxxx/yyyyy.wsdl',
// 'url' => 'https://imports-new-test.theses.fr/ThesesImports/services/DepotTEF.wsdl',
], ],
'soap' => [ 'soap' => [
'version' => SOAP_1_1, // cf. extension "php-soap" 'version' => SOAP_1_1, // cf. extension "php-soap"
'proxy_host' => 'proxy.unicaen.fr', //'proxy_host' => 'proxy.unicaen.fr',
'proxy_port' => 3128, //'proxy_port' => 3128,
], ],
], ],
'params' => [ 'params' => [
// 'idEtablissement' => 'SYGA', 'idEtablissement' => 'XXXX',
'idEtablissement' => 'NORM',
// 'ws' => 'ABES_TRF_THESE',
], ],
], ],
], ],
......
...@@ -8,16 +8,34 @@ use SoapFault; ...@@ -8,16 +8,34 @@ use SoapFault;
use stdClass; use stdClass;
use StepStar\Exception\ApiServiceException; use StepStar\Exception\ApiServiceException;
use StepStar\Service\Soap\SoapClientAwareTrait; use StepStar\Service\Soap\SoapClientAwareTrait;
use StepStar\Service\Xslt\XsltServiceAwareTrait; use Webmozart\Assert\Assert;
class ApiService class ApiService
{ {
use SoapClientAwareTrait; use SoapClientAwareTrait;
const OPERATION_DEPOSER = 'deposer'; const OPERATION_KEY__DEPOSER = 'deposer';
const OPERATION_DEPOSER_AVEC_ZIP = 'deposerAvecZip'; const OPERATION_KEY__DEPOSER_AVEC_ZIP = 'deposer_avec_zip';
// const OPERATION_DEPOSER = 'Depot';
// const OPERATION_DEPOSER_AVEC_ZIP = 'DepotAvecZip'; /**
* @var array
*/
protected array $operations = [];
/**
* @param array $operations
* @return self
*/
public function setOperations(array $operations): self
{
$message = "Clé obligatoire introuvable dans le tableau de config des opérations : %s";
Assert::keyExists($operations, self::OPERATION_KEY__DEPOSER, $message);
Assert::keyExists($operations, self::OPERATION_KEY__DEPOSER_AVEC_ZIP, $message);
$this->operations = $operations;
return $this;
}
/** /**
* @var array * @var array
...@@ -53,13 +71,12 @@ class ApiService ...@@ -53,13 +71,12 @@ class ApiService
throw new ApiServiceException("La requête 'deposer' nécessite le paramètre '$k'."); throw new ApiServiceException("La requête 'deposer' nécessite le paramètre '$k'.");
} }
$operation = self::OPERATION_DEPOSER; $operation = $this->operations[self::OPERATION_KEY__DEPOSER];
$params = $this->params; $params = $this->params;
$params['tef'] = file_get_contents($tefFilePath); $params['tef'] = file_get_contents($tefFilePath);
// $params['tef'] = file_get_contents('/tmp/tef_base64.txt');
// $params['tef'] = file_get_contents('/tmp/tef_base64_dumontier.txt');
if ($zipFilePath !== null) { if ($zipFilePath !== null) {
$operation = self::OPERATION_DEPOSER_AVEC_ZIP; $operation = $this->operations[self::OPERATION_KEY__DEPOSER_AVEC_ZIP];
$params['zip'] = base64_encode(file_get_contents($zipFilePath)); $params['zip'] = base64_encode(file_get_contents($zipFilePath));
} }
try { try {
......
...@@ -17,6 +17,7 @@ class ApiServiceFactory implements FactoryInterface ...@@ -17,6 +17,7 @@ class ApiServiceFactory implements FactoryInterface
/** @var array $config */ /** @var array $config */
$config = $container->get('Config'); $config = $container->get('Config');
$operations = $config['step_star']['api']['operations'];
$params = $config['step_star']['api']['params']; $params = $config['step_star']['api']['params'];
/** @var SoapClient $soapClient */ /** @var SoapClient $soapClient */
...@@ -24,6 +25,7 @@ class ApiServiceFactory implements FactoryInterface ...@@ -24,6 +25,7 @@ class ApiServiceFactory implements FactoryInterface
$service = new ApiService(); $service = new ApiService();
$service->setSoapClient($soapClient); $service->setSoapClient($soapClient);
$service->setOperations($operations);
$service->setParams($params); $service->setParams($params);
return $service; return $service;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment