{"id":21,"date":"2022-06-19T18:47:00","date_gmt":"2022-06-19T18:47:00","guid":{"rendered":"https:\/\/olyareri.nl\/?p=21"},"modified":"2022-07-01T18:50:31","modified_gmt":"2022-07-01T18:50:31","slug":"keeping-mtom-relaxed-for-oracle-soa-suite-12-2-1-3","status":"publish","type":"post","link":"https:\/\/olyareri.nl\/?p=21","title":{"rendered":"Keeping MTOM Relaxed for Oracle SOA Suite 12.2.1.3"},"content":{"rendered":"\n<p><strong>MTOM is used in SOAP to separate binary attachments from the actual XML payload in a request or response. Oracle SOA Suite gracefully supports MTOM simply by defining the MTOM policy on the composite level. However, since Oracle SOA Suite 12.2.1.3 the MTOM policy implementation changed, enforcing MTOM more strictly than before. Potentially breaking your existing implementation. We will briefly show the scenario in which your service implementation can break, followed by the solution.<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What changed?<\/h2>\n\n\n\n<p>Imagine a SOAP PDF Document Service, which enables clients to fetch a PDF document based on a DocumentID.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.qualogy.com\/static\/upload\/lightbox\/935dbb7e-02dc-45f3-a0a2-894d9890d5fa\/Fig+1.png\"><img decoding=\"async\" src=\"https:\/\/www.qualogy.com\/static\/upload\/center-mw\/935dbb7e-02dc-45f3-a0a2-894d9890d5fa\/Fig+1.png\" alt=\"Fig 1\"\/><\/a><figcaption>Fig 1: PDFService composite<\/figcaption><\/figure>\n\n\n\n<p>The request consists of a documentID string element, the response is a base64Binary element as defined in the WSDL (figure 2).<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;\n&lt;wsdl:definitions name=\"PDFService\"\n                  targetNamespace=\"http:\/\/qualogy.com\/SOAMTOM\/PDFService\/PDFService\"\n                  xmlns:tns=\"http:\/\/qualogy.com\/SOAMTOM\/PDFService\/PDFService\"\n                  xmlns:wsdl=\"http:\/\/schemas.xmlsoap.org\/wsdl\/\"&gt;\n\t&lt;wsdl:types&gt;\n\t\t&lt;schema xmlns=\"http:\/\/www.w3.org\/2001\/XMLSchema\"\n\t\t        targetNamespace=\"http:\/\/qualogy.com\/SOAMTOM\/PDFService\/PDFService\"\n\t\t        elementFormDefault=\"qualified\"&gt;\n\t\t\t&lt;element name=\"DocumentID\"\n\t\t\t         type=\"string\"\/&gt;\n\t\t\t&lt;element name=\"base64Binary\"\n\t\t\t         type=\"base64Binary\"\/&gt;\n\t\t&lt;\/schema&gt;\n\t&lt;\/wsdl:types&gt;\n\t&lt;wsdl:message name=\"requestMessage\"&gt;\n\t\t&lt;wsdl:part name=\"request\"\n\t\t           element=\"tns:DocumentID\"\/&gt;\n\t&lt;\/wsdl:message&gt;\n\t&lt;wsdl:message name=\"replyMessage\"&gt;\n\t\t&lt;wsdl:part name=\"document\"\n\t\t           element=\"tns:base64Binary\"\/&gt;\n\t&lt;\/wsdl:message&gt;\n\t&lt;wsdl:portType name=\"execute_ptt\"&gt;\n\t\t&lt;wsdl:operation name=\"getDocument\"&gt;\n\t\t\t&lt;wsdl:input message=\"tns:requestMessage\"\/&gt;\n\t\t\t&lt;wsdl:output message=\"tns:replyMessage\"\/&gt;\n\t\t&lt;\/wsdl:operation&gt;\n\t&lt;\/wsdl:portType&gt;\n&lt;\/wsdl:definitions&gt;<\/code><\/pre>\n\n\n\n<p><em><strong>Fig 2: PDFService.wsdl<\/strong><\/em><\/p>\n\n\n\n<p>The request for the PDF document is a simple string element, so no real use for enforcing MTOM on the request itself.&nbsp; In SOA Suite 12c this was still possible by defining the MTOM policy on the composite and keep it disabled. This way the request did not have to comply with the MTOM policy, but it did instruct SOA Suite to apply MTOM on the response message (see fig 3).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.qualogy.com\/static\/upload\/lightbox\/adfcb5ee-7b83-4f33-b57e-5aea082e3837\/Fig+3.png\"><img decoding=\"async\" src=\"https:\/\/www.qualogy.com\/static\/upload\/center-mw\/adfcb5ee-7b83-4f33-b57e-5aea082e3837\/Fig+3.png\" alt=\"Fig 3\"\/><\/a><figcaption>Fig 3: WSMTOM Policy disabled<\/figcaption><\/figure>\n\n\n\n<p>Since Oracle SOA Suite 12.2.1.3 disabling this policy will completely disable all MTOM functionality. The only way of getting SOA Suite to send an MTOM response document is to enable the MTOM policy as well. Thus also enforcing clients to call this service with MTOM enabled. In effect breaking the client interface (figure 4).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.qualogy.com\/static\/upload\/lightbox\/d13b0a00-5578-4a6c-b6f1-b222b84eddc4\/Fig+4.png\"><img decoding=\"async\" src=\"https:\/\/www.qualogy.com\/static\/upload\/center-mw\/d13b0a00-5578-4a6c-b6f1-b222b84eddc4\/Fig+4.png\" alt=\"Fig 4\"\/><\/a><figcaption>Fig 4: Error calling an MTOM enabled service while not enforcing MTOM on the client side<\/figcaption><\/figure>\n\n\n\n<p>As one can see based on figure 5 and 6 there is no big difference between MTOM messages except for a content-type on the HTTP header of the request. To be quite honest, the change to clients is minimal. However, a change is a change and clients are not always willing or capable to adapt.<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>POST http:<em>\/\/localhost:7001\/soa-infra\/services\/default\/PDFService\/PDFService HTTP\/1.1<\/em>\nContent-Type: text\/xml;charset=UTF-8\nSOAPAction:\"execute\"\n\n&lt;soapenv:Envelope xmlns:soapenv=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" xmlns:pdf=\"http:\/\/qualogy.com\/SOAMTOM\/PDFService\/PDFService\"&gt;\n  &lt;soapenv:Header\/&gt;\n  &lt;soapenv:Body&gt;\n    &lt;pdf:DocumentID&gt;12&lt;\/pdf:DocumentID&gt;\n  &lt;\/soapenv:Body&gt;\n&lt;\/soapenv:Envelope&gt;<\/code><\/pre>\n\n\n\n<p><em><strong>Fig 5: SOAP request without MTOM<\/strong><\/em><\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>POST http:<em>\/\/localhost:7001\/soa-infra\/services\/default\/PDFService\/PDFService HTTP\/1.1<\/em>\nContent-Type: multipart\/related; type=\"application\/xop+xml\"; start=\"&lt;rootpart@soapui.org&gt;\"; start-info=\"text\/xml\"; boundary=\"----=_Part_7_1660008608.1566398322338\"\nSOAPAction:\"execute\"\nMIME-Version:1.0\n\n------=_Part_7_1660008608.1566398322338\nContent-Type: application\/xop+xml; charset=UTF-8; type=\"text\/xml\"\nContent-Transfer-Encoding: 8bit\nContent-ID:&lt;rootpart@soapui.org&gt;\n&lt;soapenv:Envelope xmlns:soapenv=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" xmlns:pdf=\"http:\/\/qualogy.com\/SOAMTOM\/PDFService\/PDFService\"&gt;\n  &lt;soapenv:Header\/&gt;\n  &lt;soapenv:Body&gt;\n    &lt;pdf:DocumentID&gt;12&lt;\/pdf:DocumentID&gt;\n  &lt;\/soapenv:Body&gt;\n&lt;\/soapenv:Envelope&gt;\n------=_Part_7_1660008608.1566398322338--<\/code><\/pre>\n\n\n\n<p><em><strong>&nbsp;Fig 6: SOAP request with MTOM enabled<\/strong><\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution<\/h2>\n\n\n\n<p>Luckily, we were not the first encountering this issue, and searching Oracle Support quickly found us a patch. The patch can be found using patch number 29026751.<\/p>\n\n\n\n<p><em>Patch 29026751: NEED TO BIND WSMTOM_POLICY TO REQUEST AND RESPONSE SEPARATELY<br>BPEL Is Not Accepting The Request Received From OSB Which Is Not In The MTOM Format(Oracle 12.2.1.3)&nbsp;<strong>(Doc ID 2497644.1)<\/strong><\/em><br>With associated bug:&nbsp;<em>Bug 28972821: NEED TO CONFIGURE SEPARATE WSMTOM_POLICIES FOR REQUEST AND RESPONSE<\/em><\/p>\n\n\n\n<p>How to apply the solution however, was less obvious (figure 7)?<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.qualogy.com\/static\/upload\/lightbox\/86fe2b78-8df8-4ee2-badb-343f4828b10d\/Fig+7.png\"><img decoding=\"async\" src=\"https:\/\/www.qualogy.com\/static\/upload\/center-mw\/86fe2b78-8df8-4ee2-badb-343f4828b10d\/Fig+7.png\" alt=\"Fig 7\"\/><\/a><figcaption>Fig 7: Solution instructions after applying patch<\/figcaption><\/figure>\n\n\n\n<p>After decompiling the patch, we have extracted how to use the relaxed MTOM policy. Just add the property &#8220;<strong>oracle.webservices.wsmtompolicy.processrequest<\/strong>&#8221; onto the binding in the composite, and assign the value \u201c<strong>relax<\/strong>\u201d (see figure 8).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.qualogy.com\/static\/upload\/lightbox\/0389f4e5-f91e-49e8-972e-ccebf06e22b2\/Fig+8.png\"><img decoding=\"async\" src=\"https:\/\/www.qualogy.com\/static\/upload\/center-mw\/0389f4e5-f91e-49e8-972e-ccebf06e22b2\/Fig+8.png\" alt=\"Fig 8\"\/><\/a><figcaption>Fig 8: Relaxed MTOM composite property<\/figcaption><\/figure>\n\n\n\n<p>After applying the patch and adding the property, we were once again able to call the service without MTOM on the request. Giving us a nice MTOM attachment as response (figure 9).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.qualogy.com\/static\/upload\/lightbox\/c45c6874-9ab6-4dfd-b24f-23cf6253d67b\/Fig+9.png\"><img decoding=\"async\" src=\"https:\/\/www.qualogy.com\/static\/upload\/center-mw\/c45c6874-9ab6-4dfd-b24f-23cf6253d67b\/Fig+9.png\" alt=\"Fig 9\"\/><\/a><figcaption>Fig 9: MTOM-less request, but MTOM response<\/figcaption><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/twitter.com\/intent\/tweet?url=http%3A%2F%2Fiqc.ms%2Fg2q&amp;text=Keeping+MTOM+Relaxed+for+Oracle+SOA+Suite+12.2.1.3\"><\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>MTOM is used in SOAP to separate binary attachments from the actual XML payload in a request or response. Oracle SOA Suite gracefully supports MTOM simply by defining the MTOM policy on the composite level. However, since Oracle SOA Suite 12.2.1.3 the MTOM policy implementation changed, enforcing MTOM more strictly than before. Potentially breaking your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/olyareri.nl\/index.php?rest_route=\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/olyareri.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/olyareri.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/olyareri.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/olyareri.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21"}],"version-history":[{"count":2,"href":"https:\/\/olyareri.nl\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":23,"href":"https:\/\/olyareri.nl\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions\/23"}],"wp:attachment":[{"href":"https:\/\/olyareri.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/olyareri.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/olyareri.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}