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
Loading
Loading
Loading
Loading
+0 −81
Original line number Diff line number Diff line
<?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>
+10 −7
Original line number Diff line number Diff line
@@ -91,8 +91,7 @@ return [
        'api' => [
            'soap_client' => [
                'wsdl' => [
//                    'url' => 'https://imports-test.theses.fr/services/DepotTEF.wsdl',
////                    'url' => 'https://imports-new-test.theses.fr/ThesesImports/services/DepotTEF.wsdl',
                    'url' => 'https://xxxx/yyyyy.wsdl',
                ],
                'soap' => [
                    'version' => SOAP_1_1, // cf. extension "php-soap"
@@ -100,10 +99,14 @@ return [
                    //'proxy_port' => 3128,
                ],
            ],
            'operations' => [
//                'deposer' => 'deposer',
//                'deposer_avec_zip' => 'deposerAvecZip',
                'deposer' => 'Depot',
                'deposer_avec_zip' => 'DepotAvecZip',
            ],
            'params' => [
//                'idEtablissement' => 'SYGA',
                'idEtablissement' => 'NORM',
//                'ws' => 'ABES_TRF_THESE',
                'idEtablissement' => 'XXXX',
            ],
        ],
        'notification' => [
+4 −7
Original line number Diff line number Diff line
@@ -13,19 +13,16 @@ return [
        'api' => [
            'soap_client' => [
                'wsdl' => [
                    'url' => 'https://imports-test.theses.fr/services/DepotTEF.wsdl',
//                    'url' => 'https://imports-new-test.theses.fr/ThesesImports/services/DepotTEF.wsdl',
                    'url' => 'https://xxxxx/yyyyy.wsdl',
                ],
                'soap' => [
                    'version' => SOAP_1_1, // cf. extension "php-soap"
                    'proxy_host' => 'proxy.unicaen.fr',
                    'proxy_port' => 3128,
                    //'proxy_host' => 'proxy.unicaen.fr',
                    //'proxy_port' => 3128,
                ],
            ],
            'params' => [
//                'idEtablissement' => 'SYGA',
                'idEtablissement' => 'NORM',
//                'ws' => 'ABES_TRF_THESE',
                'idEtablissement' => 'XXXX',
            ],
        ],
    ],
+26 −9
Original line number Diff line number Diff line
@@ -8,16 +8,34 @@ use SoapFault;
use stdClass;
use StepStar\Exception\ApiServiceException;
use StepStar\Service\Soap\SoapClientAwareTrait;
use StepStar\Service\Xslt\XsltServiceAwareTrait;
use Webmozart\Assert\Assert;

class ApiService
{
    use SoapClientAwareTrait;

    const OPERATION_DEPOSER = 'deposer';
    const OPERATION_DEPOSER_AVEC_ZIP = 'deposerAvecZip';
//    const OPERATION_DEPOSER = 'Depot';
//    const OPERATION_DEPOSER_AVEC_ZIP = 'DepotAvecZip';
    const OPERATION_KEY__DEPOSER = 'deposer';
    const OPERATION_KEY__DEPOSER_AVEC_ZIP = 'deposer_avec_zip';

    /**
     * @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
@@ -53,13 +71,12 @@ class ApiService
            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['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) {
            $operation = self::OPERATION_DEPOSER_AVEC_ZIP;
            $operation = $this->operations[self::OPERATION_KEY__DEPOSER_AVEC_ZIP];
            $params['zip'] = base64_encode(file_get_contents($zipFilePath));
        }
        try {
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ class ApiServiceFactory implements FactoryInterface
        /** @var array $config */
        $config = $container->get('Config');

        $operations = $config['step_star']['api']['operations'];
        $params = $config['step_star']['api']['params'];

        /** @var SoapClient $soapClient */
@@ -24,6 +25,7 @@ class ApiServiceFactory implements FactoryInterface

        $service = new ApiService();
        $service->setSoapClient($soapClient);
        $service->setOperations($operations);
        $service->setParams($params);

        return $service;