Changes for page Endpoint Check
Last modified by Danniar Firdausy on 2024/09/04 10:26
From version 38.1
edited by Erik Bakker
on 2022/06/12 09:38
on 2022/06/12 09:38
Change comment:
There is no comment for this version
To version 30.2
edited by Erik Bakker
on 2022/06/10 13:23
on 2022/06/10 13:23
Change comment:
Update document after refactoring.
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - Securing your SOAP Webservice1 +novice-file-based-connectivity-characterset - Content
-
... ... @@ -1,111 +1,104 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 - When settingupapoint atwhichyour customerscantalkto youeMagizoffersvariousmethodsof creatingsuch a point. One ofthose optionsisby hostinga SOAP Webservice ineMagizthathandlesXMLmessages asynchronously or synchronously. In this microlearning, we willzoom in on thepartthatsecurityplaysonaclientlevelwhen hostingaSOAP web service.2 +In some cases, you want to treat each unique part of your input file as its message instead of processing the complete file as its message. In this microlearning, we will learn how you can process a (large) file on a per-line basis. 3 3 4 -Should you have any questions, please contact academy@emagiz.com. 4 +Should you have any questions, please contact [[academy@emagiz.com>>mailto:academy@emagiz.com]]. 5 5 6 -* Last update: June10th, 20216 +* Last update: May 31th, 2021 7 7 * Required reading time: 7 minutes 8 8 9 9 == 1. Prerequisites == 10 + 10 10 * Basic knowledge of the eMagiz platform 11 11 12 12 == 2. Key concepts == 13 -This microlearning centers around configuring your SOAP web service. 14 14 15 - Byconfiguring,wemean: Designinganddeterminingthecharacteristics oftheSOAP web service15 +This microlearning centers around learning how to process an incoming file per line. 16 16 17 -Crucial parts in the configuration are: 18 -* Operation Name 19 -* SOAP Webservice Namespace 20 -* Validation 21 -* Authentication 17 +By processing per line, we mean: Splitting up the input into discernable pieces that each will become a unique message 22 22 23 - Ofthesefourpoints,wewillzoominontheauthenticationpart ofour SOAP Webserviceinthismicrolearning.24 - 25 - ==3.SecuringyourSOAPWebservice==19 +* Easy way of reading a file line by line and sending it to eMagiz (Low on memory) 20 +* Ability to process each line based on distinctive logic that is relevant on line level 21 +* Can be used for flat file as well as XML input files 26 26 27 - Whensettingup a point at which yourcustomerscan talk to youeMagiz offersvariousmethods of creatingsuchapoint. Oneof those options is by hosting a SOAP Webservicein eMagiz that handles XMLmessages asynchronously or synchronously. In this microlearning, wewill zoom in on the part that security plays on a client level when hosting a SOAP web service.23 +== 3. Processing a File per Line == 28 28 29 -Crucial parts in the configuration are: 30 -* Operation Name 31 -* SOAP Webservice Namespace 32 -* Validation 33 -* Authentication 25 +In some cases, you want to treat each unique part of your input file as its message instead of processing the complete file as its message. In this microlearning, we will learn how you can process a (large) file on a per-line basis. 34 34 35 - Ofthesefourpoints,wewillzoomin ontheauthenticationpartofour SOAP Webserviceinthis microlearning.WhenhostingyourSOAPwebservice in the eMagizCloudtheendpoint willbeHTTPSsecuredon default. Ifyouwantto mimic the same resultfor an on-premiseenvironment youshoulddefine thevalidSSLsettings(https://my.emagiz.com/p/question/172825635700357186).27 +To make this work in eMagiz you need to navigate to the Create phase of eMagiz and open the entry flow in which you want to retrieve the file to a certain location. Within the context of this flow, we need to add functionality that will ensure that each line is read and processed separately and will become its unique message. To do so first enter "Start Editing" mode on flow level. After you have done so please add a file item reader message source to the flow. We will use this component to read and process our input file on a per-line basis. 36 36 37 - Apartfrom that aspectofsecurity, weshouldalso considerhowclientsthatcalltheSOAP Web servicewill authenticatethemselvesupon entry.WithineMagiz, weadviseatwo-stepapproach.Eachclient thatwantsto callyourSOAPWebservice should:29 +The first step would be to define the directory from which we read our messages. As always reference to the directory with the help of a property. 38 38 39 -* Send along a client certificate 40 -* Send along an API key in a SOAP Header that references to the word apiKey (i.e. apiKey) 31 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--file-item-reader-directory.png]] 41 41 42 - To verify both parts someconfiguration is needed.The first aspect,checkingforvalidclientcertificate is done on cloud level.Formore informationonhow to exactlyconfigure this pleasetakea lookat themicrolearning[Securing a hosted web servicewithcertificatesin theeMagiz Cloud](intermediate-securing-your-data-traffic-securing-a-hosted-webservice-with-certificates-in-the-emagiz-cloud.md).33 +Secondly, just as when reading the file as a whole ensure that you use a filter to retrieve only the correct files from the directory. 43 43 44 - Inthismicrolearning, we will focus onthesecond partof theconfiguration.35 +=== 3.1 Item reader Type === 45 45 46 - ===3.1APIKeyverification===37 +Now it is time to select our Item reader Type. As the help text of the eMagiz component suggest there are two choices with this component. The first (and most frequently used) option is the Flat file item reader. With this option, you can read each line within the flat file input file and output is at a separate message. The second option is called the Stax event item reader. With this option, you can read your input XML and output messages on a per-record basis. 47 47 48 - To verify whether the client hassentavalid API Key weneed tohangethefiguration withinthentry flowinheCreatehasef eMagiz. The configurationconsists of three steps:39 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--item-reader-type-options.png]] 49 49 50 -* Get value from SOAP Header 51 -* Check value against a list 52 -* Respond based on results 41 +Based on your choice the exact configuration will differ. 53 53 54 -==== 3.1.1 Get valuefromSOAP Header ====43 +==== 3.1.1 Stax Event Item Reader ==== 55 55 56 - Letus moveothe entryflow bygoingtotheCreatephase of eMagiz,openingthecorrectflow,andentering"StartEditing" mode.After youhave doneso weneedtoadda supportobject tothe flow. Thesupportweneediscalled'ComplexSOAPheader mapper'.Inthiscomponent,weneed thebottom section.45 +For the Stax event item reader, you need to define the name of the element on which you want to split the XML and define whether you want to throw an error in case no such element exists in the input file (By (de)selecting the option Strict). The default setting of eMagiz is advisable for this option. 57 57 58 -[[image:Main.Images.Microlearning.WebHome@novice- soap-webservice-connectivity-securing-your-soap-webservice--complex-soap-header-mapper.png]]47 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--stax-event-item-reader-config.png]] 59 59 60 - Herewedefineanewheader by entering a nameanda valid XPathexpression.49 +==== 3.1.2 Flat File Item Reader ==== 61 61 62 -[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--complex-soap-header-mapper-config.png]] 51 +For the Flat File item reader, there are some more choices and configurations to be made. There are three options you can choose from: 52 +- Pass through line mapper 53 +- Default line mapper 54 +- Pattern matching composite line mapper 63 63 64 - WhenyouaresatisfiedyoucanpressSavetwicetostorethesupportobject.Afterwehaveconfiguredthe supportobjectwe needtolinkit to ourwebservice inboundgateway.Todo so open thecomponent,navigatetothe advancedtabandselectthe Headermapperyouhavejust created.56 +Each of these options has some advantages and disadvantages. Adhering to the best practices of eMagiz (i.e. no transformation in the entry) the best option would be to use the pass-through line mapper. As the name suggests this option does nothing except give a string back to the flow on a per line basis. However, choosing this option means that the actual transformation from that string to XML needs to happen later in the process (most likely in the onramp) with the help of a flat-file to XML transformer (more on that component in a later course). 65 65 66 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--link-complex-soap-header-mapper.png]]58 +The other two options transform the input line into an XML output. So you win one step in the process. However, no standard eMagiz error handling is advisable when you start transforming data within the entry. So in case, something goes wrong to analyze the error will become more difficult. Furthermore, another potential disadvantage is that when one line fails the processing of the rest of the file also halts. 67 67 68 - ====3.1.2 Checkvalue against list====60 +For the remainder of this microlearning, we will assume that the option pass through line mapper is chosen. 69 69 70 - Now that we placed the value the client hasentered in theapiKey SOAP header onourmessagewe can check whether the value existsin a list of predefined valid values. To doadd two headers to the standard header enricher component in your flow.Thefirstoneensures that the apiKey is removedfrom the header (to prevent the API key from being publicly seenby others). Thesecond onesearches forthe client name that corresponds with the apiKeyandreturns the nameof theclient in the header. Thisearch actions done with the help of a SpELexpression, more on thatlater on. In this case the SpEL expressionweuse is set up asfollows: headers['spwbsrv_apiKey'] != null and {${authentication.api-keys}}.contains(headers.spwbsrv_apiKey) ? {${authentication.tenant-ids}}[{${authentication.api-keys}}.indexOf(headers.spwbsrv_apiKey)]: null62 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--flat-file-item-reader-passthrough.png]] 71 71 72 - WiththisSpELexpression,we checkwhetherthereisan APIkeyandwhetherthatapiKeycanbe foundin apredefined list.Ifsowe searchforthecorrespondingnamebasedonthe indexofwhereacertainapiKey iswithinthe list.If not the header is notcreated.Combiningthislogicinone component shouldlooksimilartothefollowing.64 +As you can see on the Basic level we are done. However, it is always good to check out the settings on the Advanced tab, especially in this case, to see if there are additional configuration options that could benefit us. The setting of most interest, in this case, is the Lines to Skip setting (default setting is 0). With this setting, you can define whether or not you want to process the header line(s) that exists within your input file. The remainder of the settings is (in most cases) good the way eMagiz has set them up. 73 73 74 -[[image:Main.Images.Microlearning.WebHome@novice- soap-webservice-connectivity-securing-your-soap-webservice--check-headers.png]]66 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--flat-file-item-reader-passthrough-advanced.png]] 75 75 76 -=== =3.1.3Respond based onresults====68 +=== 3.2 Poller === 77 77 78 - Afterwe have searched fortheAPI key in the list andwe have definedtheclient thatis sendingthe information (or not) wecanrespond to theclientwhetheror not theclient isauthorizedtocallour SOAP web service.To execute this checkwe firstneedastandardfiltercomponent. In this component,wewillcheckwhetherthe spwbsrv_clientheaderwehave justcreatedis notull.70 +Now that we have selected and configured the item reader type it becomes time to fill in the last part of the configuration, the poller. For polling eMagiz offers three options: 79 79 80 -[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--standard-filter.png]] 72 +- Fixed Delay Trigger 73 +- Fixed Rate Trigger 74 +- Cron Trigger 81 81 82 - Ifitisindeednotull we can passtheempty message back tothe clienttellingtheclientthat the messagewas delivered successfully.Iftheheaderisnull weneed totell the clientthat he/sheisunauthorizedto calltheoperation.To do so we need toaddacomponentcalled 'customerrormessage activator'. In this component,we definethemessagewe wanttogive backtotheclient in caseofanerror. Inthiscase, we simply give back 'Unauthorized'.76 +Of these options, the cron trigger is used most frequently in eMagiz. The reason being is that you can define this option via a property that you can alter without having to alter the flow version in Create. 83 83 84 -[[image:Main.Images.Microlearning.WebHome@novice- soap-webservice-connectivity-securing-your-soap-webservice--custom-error-message.png]]78 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--poller-config.png]] 85 85 86 - With all thisdone wehavesuccessfullysecuredourSOAPwebservice accordingto thebest practices.80 +After finishing all these configuration steps we can press Save to save our work and ensure that we can process the input file on a per-line basis. 87 87 88 88 == 4. Assignment == 89 89 90 - Secure aSOAPwebservice to confirmthe outlinedapproachabove.Focus ontheapiKeypart.84 +Configure an entry in which you define the component and configuration needed to process a file on a per-line basis. 91 91 This assignment can be completed with the help of the (Academy) project that you have created/used in the previous assignment. 92 92 93 93 == 5. Key takeaways == 94 94 95 -* Crucial parts in the configuration are: 96 - ** Operation Name 97 - ** SOAP Webservice Namespace 98 - ** Validation 99 - ** Authentication 100 -* Hosting your SOAP web service in the eMagiz cloud results in standard HTTPS 101 -* Use a combination of client certificate + API key for authentication 89 +* Easy way of reading a file line by line and sending it to eMagiz (Low on memory) 90 +* Ability to process each line based on distinctive logic that is relevant on line level 91 +* Can be used for flat file as well as XML input files 92 +* Try to avoid complex transformations within the entry 102 102 103 103 == 6. Suggested Additional Readings == 104 104 105 - Ifyouareinterested inthis topic and wantmoreinformation onitpleasereadthe help text provided by eMagiz.96 +There are no suggested additional readings on this topic 106 106 107 107 == 7. Silent demonstration video == 108 108 109 - {{videoattachment="novice-soap-webservice-connectivity-securing-your-soap-webservice.mp4"reference="Main.Videos.Microlearning.WebHome"/}}100 +This video demonstrates how you could have handled the assignment and gives you some context on what you have just learned. 110 110 102 +{{video attachment="novice-file-based-connectivity-processing-a-file-per-line.mp4" reference="Main.Videos.Microlearning.WebHome"/}} 103 + 111 111 )))((({{toc/}}))){{/container}}{{/container}}