Changes for page Securing your SOAP Webservice
Last modified by Danniar Firdausy on 2024/09/05 14:24
From version 42.1
edited by Eva Torken
on 2023/06/27 10:43
on 2023/06/27 10:43
Change comment:
There is no comment for this version
To version 35.2
edited by Erik Bakker
on 2022/06/12 09:35
on 2022/06/12 09:35
Change comment:
Update document after refactoring.
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - Securing your SOAP Webservice1 +novice-soap-webservice-connectivity-validate-incoming-messages - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki.e torken1 +XWiki.ebakker - Content
-
... ... @@ -1,101 +1,107 @@ 1 -{{container}}{{container layoutStyle="columns"}}((( 2 -When settingupa point atwhichyourcustomerscantalktoyoueMagizoffersvariousmethods ofcreatingsuchapoint. Oneof thoseoptionsisbyhostinga SOAP Webservicein eMagiz thathandlesXMLmessagesasynchronously or synchronously. In this microlearning, we willzoom in on thepartthatsecurity playsonaclientlevelwhen hostinga SOAP web service.1 +{{container}}{{container layoutStyle="columns"}}((( 2 +When talking to external parties via a SOAP web service you need to define in eMagiz that you want to call a SOAP web service so eMagiz will form a correct SOAP message. On top of the call there is a support object in eMagiz that will help you with the analysis of your problems when calling the SOAP web service. In this microlearning, we will learn how to call a SOAP web service from eMagiz. 3 3 4 4 Should you have any questions, please contact academy@emagiz.com. 5 5 6 +* Last update: April 1st, 2022 7 +* Required reading time: 5 minutes 8 + 6 6 == 1. Prerequisites == 7 7 * Basic knowledge of the eMagiz platform 8 8 9 9 == 2. Key concepts == 10 -This microlearning centers around c onfiguringyourSOAPweb13 +This microlearning centers around calling a SOAP Webservice. 11 11 12 - By configuring, we mean:DesigninganddeterminingthecharacteristicsoftheSOAPweb service15 +With SOAP, we mean: A messaging protocol specification for exchanging structured information in the implementation of web services in computer networks. 13 13 14 -Crucial parts in the configuration are: 15 -* Operation Name 16 -* SOAP Webservice Namespace 17 -* Validation 18 -* Authentication 17 +* To call a REST Webservice you need either: 18 + ** A Web Service Outbound Gateway 19 +* Critical information when configuring this component: 20 + ** URL 21 + ** Retry Advice 22 + ** Error Handling 23 + ** Authentication 24 + 25 +== 3. Calling a SOAP Webservice == 19 19 20 - Ofthesefourpoints,we willzoomin onthe authenticationpart of our SOAPWebservicein this microlearning.27 +When talking to external parties via a SOAP web service you need to define in eMagiz that you want to call a SOAP web service so eMagiz will form a correct SOAP message. On top of the call there is a support object in eMagiz that will help you with the analysis of your problems when calling the SOAP web service. In this microlearning, we will learn how to call a SOAP web service from eMagiz. 21 21 22 - ==3.SecuringyourSOAPWebservice==29 +Calling a SOAP Webservice within eMagiz can be done with the help of a Web Service Outbound Gateway. To correctly configure this component you need to consider the following elements: 23 23 24 -When setting up a point at which your customers can talk to you eMagiz offers various methods of creating such a point. One of those options is by hosting a SOAP Webservice in eMagiz that handles XML messages asynchronously or synchronously. In this microlearning, we will zoom in on the part that security plays on a client level when hosting a SOAP web service. 25 - 26 -Crucial parts in the configuration are: 27 -* Operation Name 28 -* SOAP Webservice Namespace 29 -* Validation 31 +* URL 32 +* Retry Advice 33 +* Error Handling 30 30 * Authentication 31 31 32 - Of thesefour points,we willzoominontheauthenticationpartof our SOAP Webservicein this microlearning.Whenhosting your SOAP webservicee eMagiz Cloudtheendpointwillbe HTTPS secured on default. If youwanttomimicthe sameresult foran on-premise environmentyou shoulddefinethe validSSL settings, asexplainedinhis[[Q&A>>https://my.emagiz.com/p/question/172825635700357186||target="blank"]].36 +We will discuss the first three items in this list in this microlearning. In the microlearnings that will follow this microlearning, we will delve deeper into various authentication possibilities. 33 33 34 - Apartfromthat aspect ofsecurity,weshouldalsoconsiderhowclientsthat call the SOAP Webwill authenticatethemselves uponentry.WithineMagiz,weadvise atwo-stepapproach.Each clientthatwants to callyourSOAP Webserviceshould:38 +Before we delve into the configuration of the component let us first move to Create and open an exit flow in which we want to call the SOAP Webservice. When you open the exit flow it will look similar to this: 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) 40 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-calling-a-soap-webservice--exit-flow-starting-point.png]] 38 38 39 - Toverify bothpartssomeconfigurationis needed.The firstaspect, checkingforavalidclientcertificateisdone on cloud level. For moreinformation onhowtoexactlyconfigurethis pleasetake a lookatthemicrolearning [Securing a hostedweb servicewith certificates in the eMagiz Cloud](intermediate-securing-your-data-traffic-securing-a-hosted-webservice-with-certificates-in-the-emagiz-cloud.md).42 +Now that we have opened the flow and are in "Start Editing" mode we need to add the web service outbound gateway to start with. 40 40 41 - In thismicrolearning, wewill focusn thed partoftheconfiguration.44 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-calling-a-soap-webservice--web-service-outbound-component.png]] 42 42 43 -=== 3.1 APIKey verification===46 +=== 3.1 URL === 44 44 45 - Toverifywhetherthe client hassent avalidAPIKeywe needtochangetheconfigurationwithin the entryflowintheCreatephaseofeMagiz.Theconfiguration consists of threesteps:48 +Now that we have added the correct component to the canvas it has become time to configure the component correctly. The first thing to configure when calling a SOAP Webservice is determining and registering the endpoint (URL) eMagiz should call to deliver the message too. As always in scenarios where an information element can change between environments, you should use a property reference and determine the correct value on a per-environment basis. 46 46 47 -* Get value from SOAP Header 48 -* Check value against a list 49 -* Respond based on results 50 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-calling-a-soap-webservice--web-service-outbound-component-url.png]] 50 50 51 -=== =3.1.1Getvalue fromSOAP Header====52 +=== 3.2 Retry Advice === 52 52 53 - Letusmovetothe entryflowby goingtotheCreatephaseofeMagiz, opening thecorrectflow,and entering"StartEditing"mode.Afteryou have donesoweneedtoadda support objectto theflow.Thesupportwe neediscalled'ComplexSOAPheadermapper'.In thiscomponent, weneedthebottomsection.54 +The second setting we need to configure is the retry advice. With retry advice, you can guard your solution against temporary connection losses between eMagiz and the external party. As this can happen from time to time the best practice is to configure such a Retry Advice on every Web Service Outbound component. To add the Retry Advice move to the Advanced tab and move down to the Request handler advice chain segment. Within this segment, you will see a button called Retry Advice. 54 54 55 -[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity- securing-your-soap-webservice--complex-soap-header-mapper.png]]56 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-calling-a-soap-webservice--web-service-outbound-component-retry-advice-button.png]] 56 56 57 - Herewedefineanewheader by enteringa nameandavalidXPath expression.58 +When you click on the Retry Advice button you will be prompted with a pop-up. In here you need to configure the exact settings 58 58 59 -[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity- securing-your-soap-webservice--complex-soap-header-mapper-config.png]]60 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-calling-a-soap-webservice--web-service-outbound-component-retry-advice-pop-up-empty.png]] 60 60 61 -When you are satisfied you can press Save twice to store the support object. After we have configured the support object we need to link it to our web service inbound gateway. To do so open the component, navigate to the advanced tab and select the Header mapper you have just created. 62 +The best practice for this configuration is as follows for asynchronous solutions: 63 +* Select the option called Simple Retry Policy 64 +* Set the max attempts at 6 65 +* Select the Fixed back off policy 66 +* Set the backoff period at 5000 (ms) 62 62 63 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--link-complex-soap-header-mapper.png]]68 +When you have done so the configuration should look as follows. The only thing left is to press Save to save your Retry Advice configuration 64 64 65 - ==== 3.1.2 Check valuest====70 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-calling-a-soap-webservice--web-service-outbound-component-retry-advice-pop-up-filled-in.png]] 66 66 67 - Nowthatwe placed the value the client has entered in the apiKey SOAP headern ourmessage we cancheck whether the value exists in a list of predefined valid values. To do add two headers to the standard header enricher component in your flow. The first one ensures that the apiKey is removed from the header (to prevent the API key from beingpublicly seen by others). The second one searches for the client name that corresponds with the apiKey and returns the name of the client in the header. This search action is done with the help of a SpEL expression, more on that later on. In this case the SpEL expression we use is set up as follows:72 +=== 3.3 Error Handling === 68 68 69 - {{code}}headers['spwbsrv_apiKey']!=null and {${authentication.api-keys}}.contains(headers.spwbsrv_apiKey)?{${authentication.tenant-ids}}[{${authentication.api-keys}}.indexOf(headers.spwbsrv_apiKey)]:null{{/code}}74 +When calling a SOAP Web service with the configuration we have defined up till here you could suffer from cryptic error response you get back when the SOAP web service call fails. To improve the error handling to make your life easier when analyzing the problem you need to add a support object to the canvas and link it to the web service outbound gateway. This support object is named "Detailed SOAP Fault Message Resolver". 70 70 71 - WiththisSpEL expression,weheck whetherthereis an API keyandwhetherthat apiKeycan befoundina predefinedlist.If sowe searchforthe correspondingnamebasedonheindexofwhereartainapiKeyiswithinthe list.Ifnottheheaderis not created.Combiningthislogic inone componenthould look similar to the following.76 +To link the support object to your web service outbound gateway you open the web service outbound gateway, navigate to the Advanced tab, and select the Fault message resolver. Afterward press Save to save the link between the components. 72 72 73 -[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity- securing-your-soap-webservice--check-headers.png]]78 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-calling-a-soap-webservice--web-service-outbound-component-fault-message-resolver.png]] 74 74 75 - ====3.1.3Respond basedon results====80 +Now that we have configured the HTTP Outbound component to our liking we can press Save on the component level to store our changes. As a result the flow will look as follows: 76 76 77 - After we havesearched for the API keyinthe listand wehave defined theclient that is sendingtheinformation (ornot) wecanrespond to the client whether ornot the client isauthorized to call our SOAPweb. Toxecute this check we firstneedastandard filter component. In thiscomponent,wewill check whether the spwbsrv_client headerwe have just created isnot null.82 +[[image:Main.Images.Microlearning.WebHome@microlearning/novice-soap-webservice-connectivity-calling-a-soap-webservice--flow-result.png]] 78 78 79 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--standard-filter.png]]84 +== 4. Assignment == 80 80 81 -If it is indeed not null we can pass the empty message back to the client telling the client that the message was delivered successfully. If the header is null we need to tell the client that he/she is unauthorized to call the operation. To do so we need to add a component called 'custom error message activator'. In this component, we define the message we want to give back to the client in case of an error. In this case, we simply give back 'Unauthorized'. 86 +Build a flow within your project in which you do a call to an external party that hosts a SOAP web service. 87 +This assignment can be completed with the help of the (Academy) project that you have created/used in the previous assignment. 82 82 83 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--custom-error-message.png]]89 +== 5. Key takeaways == 84 84 85 -With all this done we have successfully secured our SOAP web service according to the best practices. 86 - 87 -== 4. Key takeaways == 88 - 89 -* Crucial parts in the configuration are: 90 - ** Operation Name 91 - ** SOAP Webservice Namespace 92 - ** Validation 91 +* eMagiz will create a valid SOAP message when using this component 92 +* eMagiz provides a support object for better error handling of SOAP faults 93 +* There are four key configuration elements: 94 + ** URL 95 + ** Retry Advice 96 + ** Error Handling 93 93 ** Authentication 94 -* Hosting your SOAP web service in the eMagiz cloud results in standard HTTPS 95 -* Use a combination of client certificate + API key for authentication 96 96 97 -== 5. Suggested Additional Readings ==99 +== 6. Suggested Additional Readings == 98 98 99 99 If you are interested in this topic and want more information on it please read the help text provided by eMagiz. 100 100 103 +== 7. Silent demonstration video == 104 + 105 +{{video attachment="novice-soap-webservice-connectivity-calling-a-soap-webservice.mp4" reference="Main.Videos.Microlearning.WebHome"/}} 106 + 101 101 )))((({{toc/}}))){{/container}}{{/container}}