Konfigurace (KS webAPI): Porovnání verzí

Z Prirucky
 
Řádek 5: Řádek 5:
== Konfigurační soubor ==
== Konfigurační soubor ==


Konfigurace se provádí v konfiguračním souboru Windows služby [[KS aplikační server]]
Konfigurace se provádí v konfiguračním souboru Windows služby [[KS aplikační server]].
* '''''ASServer.exe.config''''' - soubor je uložen v adresáři ''ASServer'', v umístění instance [[KS aplikační server]], které bylo vybráno pro instalaci [[KS aplikační server]].
* '''''ASServer.exe.config''''' - soubor je uložen v adresáři ''ASServer'', v umístění instance [[KS aplikační server]], které bylo vybráno pro instalaci [[KS aplikační server]].



Aktuální verze z 19. 3. 2025, 10:52

Základní konfigurace webové služby KS webAPI se provádí v konfiguračním souboru ASServer.exe.config, který je součástí Windows služby KS aplikační server (AS). V tomto souboru se nastavuje transportní protokol (HTTP/HTTPS), komunikační protokol (SOAP/REST), adresa webové služby (Endpoint), certifikát pro zabezpečení komunikace, atd. Toto nastavení je potřeba pro zpřístupnění webové služby klientské aplikaci.

Nastavení uživatelských účtů a oprávnění k přenášeným údajům se nastavuje v aplikaci AS Seance Manager (ASSM).

Konfigurační soubor

Konfigurace se provádí v konfiguračním souboru Windows služby KS aplikační server.

V konfiguračním souboru se nastaví Endpoint, Binding, Behavior, případně jiná nastavení.

Příklad

Níže je uvedena vzorová konfigurace, která využívá zabezpečení s ověřením uživatelského jména na straně klienta a proto je potřeba nastavit certifikát v části <serviceCertificate>

SOAP a REST lze využívat souběžně.

Vzorová konfigurace SOAP

<system.serviceModel>
  <services>  
    <service name="KSProgram.AS.WCF.KSWebAPI" behaviorConfiguration="KSWebAPIBehavior">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:9001/KSAsServer/WebService/WebAPI"/>
        </baseAddresses>
      </host>

      <endpoint address=""
                binding="wsHttpBinding"
                bindingConfiguration="KSWebAPIBinding"
                contract="KSProgram.AS.WCF.IKSWebAPI" />
    </service>
  </services>
  <bindings>
      <wsHttpBinding>
        <binding name="KSWebAPIBinding">
      <security mode="Message">
   <message clientCredentialType="UserName" />
 </security>
 <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647"   
        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
      </wsHttpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior name="KSWebAPIBehavior">
  <serviceMetadata httpGetEnabled="true"/>
  <serviceDebug includeExceptionDetailInFaults="true"/>
  <serviceCredentials>
      <userNameAuthentication userNamePasswordValidationMode="Custom"  
             customUserNamePasswordValidatorType="KSProgram.AS.WCF.PasswordValidator, WCFLib"/>
   <serviceCertificate findValue="WebAPI_cert" storeLocation="LocalMachine"  
             storeName="My" x509FindType="FindBySubjectName"/>
  </serviceCredentials>
</behavior>
      </serviceBehaviors>
    </behaviors>
</system.serviceModel>


Vzorová konfigurace REST

<system.serviceModel>
	<services>
		<service name="WCFLib.KSWebAPI.RESTApi.KSWebAPIRest" behaviorConfiguration="KSWebAPIBehaviorRest">
			<endpoint address="Rest" behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="KSWebAPIBindingRest" contract="WCFLib.KSWebAPI.RESTApi.IKSWebAPIRest"/>
			<host>
				<baseAddresses>
					<add baseAddress="https://localhost:9002/KSAsServer/WebService/WebAPI"/>
				</baseAddresses>
			</host>
		</service>
	</services>
	<bindings>
		<webHttpBinding>
			<binding name="KSWebAPIBindingRest" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="00:10:00" receiveTimeout="00:10:00" crossDomainScriptAccessEnabled="false">
				<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/>
				<security mode="Transport">
				</security>
			</binding>
		</webHttpBinding>
	</bindings>
	<behaviors>
		<serviceBehaviors>
			<behavior name="KSWebAPIBehaviorRest">
				<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
				<serviceDebug includeExceptionDetailInFaults="true"/>
				<serviceCredentials>
					<serviceCertificate findValue="4564qwe23gdf8gd32f4fhf6f12s3a1sd" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySerialNumber"/>
				</serviceCredentials>
			</behavior>
		</serviceBehaviors>
		<endpointBehaviors>
			<behavior name="webBehavior">
				<webHttp defaultOutgoingResponseFormat="Json"/>
			</behavior>
		</endpointBehaviors>
	</behaviors>
	<standardEndpoints>
		<webScriptEndpoint>
			<standardEndpoint crossDomainScriptAccessEnabled="true">
			</standardEndpoint>
		</webScriptEndpoint>
	</standardEndpoints>
	<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>

AS Seance Manager - Úloha č. 73

AS Seance Manager (dále ASSM) je aplikace, která byla nainstalována společně s AS a slouží ke správě AS (spouštění instancí AS, konfigurace úloh, kontrola stavu úloh, atd.). ASSM je umístěn v adresáři, který byl vybrán pro instalaci AS - ...\KS-AS\ASSeanceManager\ASSeanceManager.exe.

V případě KS webAPI je zde typ úlohy

  • Webová služba KSwebAPI (Kód = 73) v seznamu Typ úlohy. V části Nastavení webové služby se provádí nastavení uživatelských účtů pro autentizaci.

ASSM (soubor ASSeanceManager.exe) je nutné spouštět jako správce.

Nastaveni-as-seancemanager-webapi.jpg

Správa uživatelů

V AS Seance Manager se provádí nastavení uživatelských účtů pro autentizaci. V sekci 'Nastavení webové služby' se po stisku tlačítka Správa uživatelů otevře příslušné okno.

KSwebAPI-Konektor Advanto-SpravaUzivatelu.png

Oprávnění na položky

V AS Seance Manager se provádí nastavení oprávnění 'Čtení' a 'Zápis' na položky pro jednotlivé skupiny položek. V sekci 'Nastavení webové služby' se po stisku tlačítka 'Přístupová práva' otevře příslušné okno.

Pristupova-prava-polozky-ks-webapi.jpg

Odkazy