Changes for page Securing your SOAP Webservice
Last modified by Danniar Firdausy on 2024/09/05 14:24
From version 39.1
edited by Erik Bakker
on 2022/08/22 14:57
on 2022/08/22 14:57
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,108 +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: May 31th, 2021 7 +* Required reading time: 7 minutes 8 + 6 6 == 1. Prerequisites == 10 + 7 7 * Basic knowledge of the eMagiz platform 8 8 9 9 == 2. Key concepts == 10 -This microlearning centers around configuring your SOAP web service. 11 11 12 - Byconfiguring,wemean: Designinganddeterminingthecharacteristics oftheSOAP web service15 +This microlearning centers around learning how to process an incoming file per line. 13 13 14 -Crucial parts in the configuration are: 15 -* Operation Name 16 -* SOAP Webservice Namespace 17 -* Validation 18 -* Authentication 17 +By processing per line, we mean: Splitting up the input into discernable pieces that each will become a unique message 19 19 20 -Of these four points, we will zoom in on the authentication part of our SOAP Webservice in this microlearning. 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 21 21 22 -== 3. SecuringyourSOAPWebservice ==23 +== 3. Processing a File per Line == 23 23 24 - 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.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. 25 25 26 -Crucial parts in the configuration are: 27 -* Operation Name 28 -* SOAP Webservice Namespace 29 -* Validation 30 -* Authentication 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. 31 31 32 - Of thesefour points,we willzoominon theauthentication partofourSOAP Webservice in thismicrolearning.When hosting yourSOAP webservice in the eMagiz Cloud theendpointwillbeHTTPS secured ondefault.If you wanttomimicthesameresultforan on-premise environmentyou shoulddefinethevalidSSLsettings(https://my.emagiz.com/p/question/172825635700357186).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. 33 33 34 - Apart fromthataspect ofsecurity, we shouldalso consider how clients that call the SOAPWebservicewill authenticate themselves uponentry. WithineMagiz, weadvisea two-stepapproach. Each client that wants to call yourSOAP Webserviceshould:31 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--file-item-reader-directory.png]] 35 35 36 -* Send along a client certificate 37 -* Send along an API key in a SOAP Header that references to the word apiKey (i.e. apiKey) 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. 38 38 39 - Toverify both parts some configuration is needed.The firstaspect,checking fora valid client certificate isdoneon cloud level. Formore information on how to exactlyconfigure thispleasetake a look at the microlearning [Securing a hosted web service with certificates in the eMagiz Cloud](intermediate-securing-your-data-traffic-securing-a-hosted-webservice-with-certificates-in-the-emagiz-cloud.md).35 +=== 3.1 Item reader Type === 40 40 41 -In this microlearning,we will focusonthe second partftheconfiguration.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. 42 42 43 - === 3.1 APIKey verification===39 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--item-reader-type-options.png]] 44 44 45 - To verify whether the client hassent a validAPI Key we need tochangethe configurationwithin theentry flow in theCreatephase of eMagiz. Theconfigurationconsistsofthree steps:41 +Based on your choice the exact configuration will differ. 46 46 47 -* Get value from SOAP Header 48 -* Check value against a list 49 -* Respond based on results 43 +==== 3.1.1 Stax Event Item Reader ==== 50 50 51 - ====3.1.1 Get value from SOAPHeader====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. 52 52 53 - Let usmove to the entry flow bygoing to theCreate phase of eMagiz, openingtheorrect flow, andentering "Start Editing"mode. After you havee so weneedto add a supportobject to theow. Thesupport weed iscalled 'ComplexSOAP header mapper'. Inhis component, weneedthebottom section.47 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--stax-event-item-reader-config.png]] 54 54 55 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--complex-soap-header-mapper.png]]49 +==== 3.1.2 Flat File Item Reader ==== 56 56 57 -Here we define a new header by entering a name and a valid XPath expression. 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 58 58 59 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--complex-soap-header-mapper-config.png]]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). 60 60 61 - Whenyou aresatisfiedyoucan pressSavetwiceto store thesupportobject.Afterwehaveconfiguredthesupportobjectweeedtolink it toour webservice inboundgateway.Todoso openthecomponent,navigatetohe advancedtabandselecttheHeader mapperyouhavejustcreated.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. 62 62 63 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--link-complex-soap-header-mapper.png]]60 +For the remainder of this microlearning, we will assume that the option pass through line mapper is chosen. 64 64 65 - ==== 3.1.2 Check valuest====62 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--flat-file-item-reader-passthrough.png]] 66 66 67 - Nowthat we placed the valuetheclienthasnteredin the apiKeySOAP headeron our messagewecancheckwhetherthe value existsin a listof predefined valid values.Todoaddtwo headersto the standard header enricher componentyourflow. Thefirst oneensuresthattheapiKey isremoved fromtheheader(topreventtheAPI keyfrom beingpublicly seenbyothers).Thesecondone searchesfortheclientnamethat correspondswiththe apiKeyand returns the name ofthe clientthe header.Thissearch action isdonewith thehelpofaSpELexpression, moreon thatlater on.InhiscasetheSpEL expression weuse issetup as follows:headers['spwbsrv_apiKey']!= null and{${authentication.api-keys}}.contains(headers.spwbsrv_apiKey)?{${authentication.tenant-ids}}[{${authentication.api-keys}}.indexOf(headers.spwbsrv_apiKey)]:null64 +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. 68 68 69 - With this SpELexpression, weheck whetherthere isan API key and whetherthat apiKey canbefoundin a predefinedlist. If so wearch for theorrespondingnamebased on theindex ofwhereacertain apiKeyis within thelist. If not theheaderisnotcreated. Combiningthis logic inonecomponent shouldlook similar to the following.66 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--flat-file-item-reader-passthrough-advanced.png]] 70 70 71 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--check-headers.png]]68 +=== 3.2 Poller === 72 72 73 - ====3.1.3Respondbasedonresults====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: 74 74 75 -After we have searched for the API key in the list and we have defined the client that is sending the information (or not) we can respond to the client whether or not the client is authorized to call our SOAP web service. To execute this check we first need a standard filter component. In this component, we will check whether the spwbsrv_client header we have just created is not null. 72 +- Fixed Delay Trigger 73 +- Fixed Rate Trigger 74 +- Cron Trigger 76 76 77 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--standard-filter.png]]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. 78 78 79 - Ifit is indeed not null we can pass the empty messageback to the client telling the client that themessagewasdelivered successfully. If theheadersnull weneed totell the client that he/she is unauthorized tocall theoperation. To doso weneedto add acomponent called 'custom error message activator'. In this component, we define the message we want togiveback to theclient in casef anerror. Inthis case, we simplygive back 'Unauthorized'.78 +[[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-processing-a-file-per-line--poller-config.png]] 80 80 81 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--custom-error-message.png]]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. 82 82 83 -With all this done we have successfully secured our SOAP web service according to the best practices. 84 - 85 85 == 4. Assignment == 86 86 87 - 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. 88 88 This assignment can be completed with the help of the (Academy) project that you have created/used in the previous assignment. 89 89 90 90 == 5. Key takeaways == 91 91 92 -* Crucial parts in the configuration are: 93 - ** Operation Name 94 - ** SOAP Webservice Namespace 95 - ** Validation 96 - ** Authentication 97 -* Hosting your SOAP web service in the eMagiz cloud results in standard HTTPS 98 -* 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 99 99 100 100 == 6. Suggested Additional Readings == 101 101 102 - Ifyouareinterested inthis topic and wantmoreinformation onitpleasereadthe help text provided by eMagiz.96 +There are no suggested additional readings on this topic 103 103 104 104 == 7. Silent demonstration video == 105 105 106 - {{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. 107 107 102 +{{video attachment="novice-file-based-connectivity-processing-a-file-per-line.mp4" reference="Main.Videos.Microlearning.WebHome"/}} 103 + 108 108 )))((({{toc/}}))){{/container}}{{/container}}