<div dir="ltr">Thanks, I will definitely keep tabs on your progress :)</div><div class="gmail_extra"><br><div class="gmail_quote">2016-03-30 16:02 GMT+02:00 Eric Wittmann <span dir="ltr">&lt;<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Note, here are a couple of JIRA issues created for these features in case you&#39;re interested in tracking our progress on them:<br>
<br>
<a href="https://issues.jboss.org/browse/APIMAN-1072" rel="noreferrer" target="_blank">https://issues.jboss.org/browse/APIMAN-1072</a><br>
<a href="https://issues.jboss.org/browse/APIMAN-1077" rel="noreferrer" target="_blank">https://issues.jboss.org/browse/APIMAN-1077</a><span class=""><br>
<br>
-Eric<br>
<br>
On 3/30/2016 4:26 AM, Benjamin Kastelic wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Just one more thing ...<br>
If a SOAP API is published on Apiman and you request the WSDL by using<br>
the gateway endpoint URL, you get the original WSDL - address is<br>
pointing to the real endpoint URL and not the gateway endpoint URL.<br>
I have solved this temporarily by adding URL rewrite policies to all<br>
SOAP APIs, which replace the real endpoint URL with the gateway endpoint<br>
URL.<br>
I guess it would be best if this policy was handled by the gateway<br>
internally so that you wouldn&#39;t have to worry by adding a correct policy<br>
to the API configuration.<br>
<br>
2016-03-29 20:29 GMT+02:00 Benjamin Kastelic<br></span>
&lt;<a href="mailto:kastelic.benjamin@gmail.com" target="_blank">kastelic.benjamin@gmail.com</a> &lt;mailto:<a href="mailto:kastelic.benjamin@gmail.com" target="_blank">kastelic.benjamin@gmail.com</a>&gt;&gt;:<span class=""><br>
<br>
    OK, now I understand what you meant.<br>
    I believe this would be a reasonable solution :)<br>
<br>
    2016-03-29 20:18 GMT+02:00 Eric Wittmann &lt;<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br></span>
    &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;:<span class=""><br>
<br>
        My plan was unclear!  Let&#39;s go with another example:<br>
<br>
        Step 1 - the Gateway receives the following HTTP request:<br>
<br>
        ----<br>
        POST /apiman-gateway/MyOrg/soap-api/2.7 HTTP/1.1<br></span>
        Host: <a href="http://www.example.org" rel="noreferrer" target="_blank">www.example.org</a> &lt;<a href="http://www.example.org" rel="noreferrer" target="_blank">http://www.example.org</a>&gt;<div><div class="h5"><br>
        Content-Type: application/soap+xml; charset=utf-8<br>
        X-API-Key: API-KEY-FOR-ACTIVE-CLIENT<br>
        SOAPAction: ExampleAction<br>
<br>
        &lt;?xml version=&quot;1.0&quot;?&gt;<br>
        &lt;soap:Envelope xmlns:soap=&quot;<a href="http://www.w3.org/2003/05/soap-envelope" rel="noreferrer" target="_blank">http://www.w3.org/2003/05/soap-envelope</a>&quot;&gt;<br>
           &lt;soap:Header&gt;<br>
             &lt;ns1:Header1 xmlns:ns1=&quot;uri:ns1&quot;&gt;foo&lt;/ns1:Header1&gt;<br>
             &lt;ns2:Header2 xmlns:ns2=&quot;uri:ns2&quot;&gt;bar&lt;/ns2:Header2&gt;<br>
           &lt;/soap:Header&gt;<br>
           &lt;soap:Body&gt;<br>
             &lt;m:GetStockPrice xmlns:m=&quot;<a href="http://www.example.org/stock/RHT" rel="noreferrer" target="_blank">http://www.example.org/stock/RHT</a>&quot;&gt;<br>
               &lt;m:StockName&gt;Red Hat&lt;/m:StockName&gt;<br>
             &lt;/m:GetStockPrice&gt;<br>
           &lt;/soap:Body&gt;<br>
        &lt;/soap:Envelope&gt;<br>
        ----<br>
<br>
        We&#39;ll parse the first part of the envelope so that we can read<br>
        the headers and make them available to any policies.  After<br>
        that&#39;s done, we&#39;ll invoke the policy chain as per normal.<br>
        However, because it&#39;s a SOAP api, there will exist a<br>
        SOAPRequestInfo object in the policy context.  So policies can<br>
        read and/or modify the soap information.  This class might look<br>
        something like this:<br>
<br>
        public class SOAPRequestInfo {<br>
             private String action;<br>
             private String encoding;<br>
             private Map&lt;QName, SOAPHeader&gt; headers;<br>
        }<br>
<br>
        This allows interested policies (like your ws-security) policy<br>
        to have easy access to all the soap related stuff.  It also<br>
        allows you to alter these things.  Including<br>
        adding/removing/modifying the SOAP headers.<br>
<br>
        So let&#39;s assume that we have a policy which *adds* a SOAP header<br>
        (ns3:AddedHeader) and another policy which *removes* one<br>
        (ns2:Header2).  The policy code might look like this:<br>
<br>
        SOAPRequestInfo soapInfo = context.getAttribute(<br>
                 Constants.SOAP_INFO, (SOAPRequestInfo) null);<br>
        soapInfo.getHeaders().remove(new QName(&quot;uri:ns2&quot;, &quot;Header2&quot;));<br>
        soapInfo.getHeaders().put(<br>
             new QName(&quot;uri:ns3&quot;, &quot;AddedHeader&quot;),<br>
             createSoapHeader()<br>
        );<br>
<br>
<br>
        In that case, this is the HTTP request that will be sent/proxied<br>
        to the back-end API:<br>
<br>
        ----<br>
        POST / HTTP/1.1<br></div></div>
        Host: <a href="http://www.example.org" rel="noreferrer" target="_blank">www.example.org</a> &lt;<a href="http://www.example.org" rel="noreferrer" target="_blank">http://www.example.org</a>&gt;<span class=""><br>
        Content-Type: application/soap+xml; charset=utf-8<br>
        SOAPAction: ExampleAction<br>
<br>
        &lt;?xml version=&quot;1.0&quot;?&gt;<br>
        &lt;soap:Envelope xmlns:soap=&quot;<a href="http://www.w3.org/2003/05/soap-envelope" rel="noreferrer" target="_blank">http://www.w3.org/2003/05/soap-envelope</a>&quot;&gt;<br>
           &lt;soap:Header&gt;<br>
             &lt;ns1:Header1 xmlns:ns1=&quot;uri:ns1&quot;&gt;foo&lt;/ns1:Header1&gt;<br>
             &lt;ns3:AddedHeader xmlns:ns3=&quot;uri:ns3&quot;&gt;bar&lt;/ns3:AddedHeader&gt;<br>
           &lt;/soap:Header&gt;<br>
           &lt;soap:Body&gt;<br>
             &lt;m:GetStockPrice xmlns:m=&quot;<a href="http://www.example.org/stock/RHT" rel="noreferrer" target="_blank">http://www.example.org/stock/RHT</a>&quot;&gt;<br>
               &lt;m:StockName&gt;Red Hat&lt;/m:StockName&gt;<br>
             &lt;/m:GetStockPrice&gt;<br>
           &lt;/soap:Body&gt;<br>
        &lt;/soap:Envelope&gt;<br>
        ----<br>
<br>
        Sound reasonable?<br>
<br>
        -Eric<br>
<br>
<br>
        On 3/29/2016 1:42 PM, Benjamin Kastelic wrote:<br>
<br>
            If I understand you correctly Eric, only the soap:Body part<br>
            will be<br>
            forwarded to the registered API?<br>
            What if the API still needs to receive the soap:Header part?<br>
<br>
            2016-03-29 15:34 GMT+02:00 Keith Babo &lt;<a href="mailto:kbabo@redhat.com" target="_blank">kbabo@redhat.com</a><br>
            &lt;mailto:<a href="mailto:kbabo@redhat.com" target="_blank">kbabo@redhat.com</a>&gt;<br></span>
            &lt;mailto:<a href="mailto:kbabo@redhat.com" target="_blank">kbabo@redhat.com</a> &lt;mailto:<a href="mailto:kbabo@redhat.com" target="_blank">kbabo@redhat.com</a>&gt;&gt;&gt;:<span class=""><br>
<br>
                 Sounds cool to me.  Header policy will need to be QName and<br>
                 DOM-aware, so that namespace-qualified headers can be<br>
            added and<br>
                 appropriate namespace definitions can be added to the<br>
            DOM if<br>
                 required.  Of course you already know all this, but<br>
            pointing it out<br>
                 makes me feel useful.<br>
<br>
                  &gt; On Mar 29, 2016, at 8:38 AM, Eric Wittmann<br>
                 &lt;<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br></span><span class="">
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt; wrote:<br>
                  &gt;<br></span><div><div class="h5">
                  &gt; That&#39;s an interesting idea.  It&#39;d be harder to<br>
            inject the headers<br>
                 into the request than it is to inject HTTP request headers,<br>
                 obviously.  But not impossible.  We&#39;d need to be aware<br>
            of the change<br>
                 to any Content-Length that may be set.<br>
                  &gt;<br>
                  &gt; This makes the implementation slightly more<br>
            complicated, because<br>
                 I think the HTTP connector will need to be made smarter<br>
            (it will<br>
                 need to send the &lt;soap:Envelope&gt; and &lt;soap:Header&gt;<br>
            sections first,<br>
                 then just stream the remaining request body as-is.<br>
                  &gt;<br>
                  &gt; So perhaps what we have is this:<br>
                  &gt;<br>
                  &gt; 1.  &lt;?xml version=&quot;1.0&quot;?&gt;<br>
                  &gt; 2.  &lt;soap:Envelope<br>
                 xmlns:soap=&quot;<a href="http://www.w3.org/2003/05/soap-envelope" rel="noreferrer" target="_blank">http://www.w3.org/2003/05/soap-envelope</a>&quot;&gt;<br>
                  &gt; 3.    &lt;soap:Header&gt;<br>
                  &gt; 4.      &lt;ns1:Foo actor=&quot;...&quot;<br>
            xmlns:ns1=&quot;uri:ns1&quot;&gt;BAR&lt;/ns1:Foo&gt;<br>
                  &gt; 5.    &lt;/soap:Header&gt;<br>
                  &gt; 6.    &lt;soap:Body&gt;<br>
                  &gt; 7.      &lt;m:GetStockPrice<br>
                 xmlns:m=&quot;<a href="http://www.example.org/stock/Surya" rel="noreferrer" target="_blank">http://www.example.org/stock/Surya</a>&quot;&gt;<br>
                  &gt; 8.        &lt;m:StockName&gt;IBM&lt;/m:StockName&gt;<br>
                  &gt; 9.      &lt;/m:GetStockPrice&gt;<br>
                  &gt; 10.   &lt;/soap:Body&gt;<br>
                  &gt; 11. &lt;/soap:Envelope&gt;<br>
                  &gt;<br>
                  &gt; Lines 1-5 will be read and consumed by apiman<br>
            *before* any<br>
                 policies are executed.  We&#39;ll actually keep reading<br>
            until we find<br>
                 &lt;soap:Body&gt; in the request body.  We&#39;ll throw out<br>
            everything before<br>
                 line #6 from our in-memory buffer, resulting in a<br>
            buffer with just<br>
                 line #6 (and any extra bytes after that based on our<br>
            I/O chunk size).<br>
                  &gt;<br>
                  &gt; The policies will be executed, which may result in<br>
            soap headers<br>
                 being added, modified, or removed.  If all policies<br>
            pass, then we<br>
                 proxy the request to the back-end.  Normally the HTTP<br>
            connection<br>
                 would simply send all bytes from the HTTP request<br>
            as-is.  Instead,<br>
                 we&#39;ll need to *generate* new content for lines 1-5,<br>
            with the newly<br>
                 modified soap headers.  Once the generated content is<br>
            sent, then we<br>
                 send the contents of the in-memory buffer (which<br>
            contains line #6+<br>
                 any additional bytes).  After that, we proxy the<br>
            remaining bytes<br>
                 from the HTTP request as-is.<br>
                  &gt;<br>
                  &gt; This may be starting to take shape.  :)<br>
                  &gt;<br>
                  &gt; Additional thoughts?<br>
                  &gt;<br>
                  &gt; -Eric<br>
                  &gt;<br>
                  &gt; PS:  @Keith - we&#39;ll likely have a separate Policy for<br>
                 manipulating SOAP headers, rather than re-use the<br>
            existing HTTP<br>
                 headers policy.<br>
                  &gt;<br>
                  &gt; On 3/29/2016 8:13 AM, Keith Babo wrote:<br>
                  &gt;&gt; Sounds like a reasonable first step to me.  Just to<br>
            make life<br>
                 slightly<br>
                  &gt;&gt; more complicated, will the headers policy be<br>
            updated to allow<br>
                 add/remove<br>
                  &gt;&gt; of SOAP:Headers? :-)<br>
                  &gt;&gt;<br>
                  &gt;&gt; ~ keith<br>
                  &gt;&gt;<br>
                  &gt;&gt;&gt; On Mar 29, 2016, at 7:52 AM, Eric Wittmann<br>
                 &lt;<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;<br></div></div><span class="">
                  &gt;&gt;&gt; &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt;&gt; wrote:<br>
                  &gt;&gt;&gt;<br></span><div><div class="h5">
                  &gt;&gt;&gt; OK so here&#39;s what I propose (feedback welcome):<br>
                  &gt;&gt;&gt;<br>
                  &gt;&gt;&gt; *If* an API&#39;s &#39;type&#39; is set to SOAP, then we will<br>
            *always* look<br>
                 for a<br>
                  &gt;&gt;&gt; soap envelope in the body.  If no body is found or<br>
            no soap<br>
                 envelope is<br>
                  &gt;&gt;&gt; found in the body, then a standard apiman error<br>
            will be thrown.<br>
                  &gt;&gt;&gt;<br>
                  &gt;&gt;&gt; If an envelope *is* found, then we will read the<br>
            body of the HTTP<br>
                  &gt;&gt;&gt; request until we find &quot;&lt;soap:Body&gt;&quot;.  We&#39;ll<br>
            extract the<br>
                 &lt;soap:Header&gt;<br>
                  &gt;&gt;&gt; and parse its children.  While parsing, we&#39;ll<br>
            obviously keep<br>
                 the data<br>
                  &gt;&gt;&gt; we read in a memory buffer.  Once parsing is done,<br>
            we&#39;ll<br>
                 include the<br>
                  &gt;&gt;&gt; soap headers, soap action, and the global encoding<br>
            type in some<br>
                 sort<br>
                  &gt;&gt;&gt; of soapinfo object and include that in the policy<br>
            context.<br>
                  &gt;&gt;&gt;<br>
                  &gt;&gt;&gt; Finally, after all that is done, we&#39;ll process the<br>
            request as<br>
                 normal,<br>
                  &gt;&gt;&gt; executing the policy chain, then processing the<br>
            request body,<br>
                 etc. The<br>
                  &gt;&gt;&gt; entire request payload will still be processed<br>
            (remember that<br>
                 we saved<br>
                  &gt;&gt;&gt; the bytes we read in a memory buffer).<br>
                  &gt;&gt;&gt;<br>
                  &gt;&gt;&gt; So from the perspective of a policy, everything<br>
            will look identical<br>
                  &gt;&gt;&gt; except that a SOAPInfo object will be available in<br>
            the policy<br>
                 context.<br>
                  &gt;&gt;&gt;<br>
                  &gt;&gt;&gt; Thoughts?<br>
                  &gt;&gt;&gt;<br>
                  &gt;&gt;&gt; -Eric<br>
                  &gt;&gt;&gt;<br>
                  &gt;&gt;&gt; On 3/28/2016 1:48 PM, Benjamin Kastelic wrote:<br>
                  &gt;&gt;&gt;&gt; Yup, I agree. That would probably be best, since<br>
            several<br>
                 validators<br>
                  &gt;&gt;&gt;&gt; (wss4j for example) require DOM Elements<br>
                 (javax.xml.soap.SOAPHeader) to<br>
                  &gt;&gt;&gt;&gt; function.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt; Best regards,<br>
                  &gt;&gt;&gt;&gt; Benjamin<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt; 2016-03-28 19:14 GMT+02:00 Eric Wittmann<br>
                 &lt;<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;<br>
                  &gt;&gt;&gt;&gt; &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br></div></div><div><div class="h5">
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt; &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt;&gt;:<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;   Thanks!  In that case, making the headers<br>
            available as DOM<br>
                 Element<br>
                  &gt;&gt;&gt;&gt;   objects (perhaps with a simple QName based<br>
            lookup) would be<br>
                 best.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;   -Eric<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;   On 3/28/2016 12:39 PM, Keith Babo wrote:<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;       SOAP:Headers can be complex types.<br>
            WS-Security is a good<br>
                  &gt;&gt;&gt;&gt; example of<br>
                  &gt;&gt;&gt;&gt;       this in practice.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;       ~ keith<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           On Mar 28, 2016, at 11:37 AM, Eric Wittmann<br>
                  &gt;&gt;&gt;&gt;           &lt;<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;<br>
                  &gt;&gt;&gt;&gt; &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt;&lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br></div></div><div><div class="h5">
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt;&gt;&gt; wrote:<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           That&#39;s a bit hacky, but also sort of a<br>
            genius<br>
                 approach as<br>
                  &gt;&gt;&gt;&gt;           well.  I&#39;m<br>
                  &gt;&gt;&gt;&gt;           actually a little bummed I didn&#39;t think<br>
            of it.  :)<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           As for extending SOAP support - I was<br>
            thinking that<br>
                 I could<br>
                  &gt;&gt;&gt;&gt;           make the<br>
                  &gt;&gt;&gt;&gt;           relevant changes to apiman if you would<br>
            be willing<br>
                 to provide<br>
                  &gt;&gt;&gt;&gt;           feedback/guidance/testing.  My SOAP<br>
            expertise is<br>
                 quite stale<br>
                  &gt;&gt;&gt;&gt;           at this<br>
                  &gt;&gt;&gt;&gt;           point, so having some eyeballs on these<br>
            changes would be<br>
                  &gt;&gt;&gt;&gt;           very useful.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           To start off with, what pieces of the<br>
            SOAP envelope<br>
                 should<br>
                  &gt;&gt;&gt;&gt;           be extracted<br>
                  &gt;&gt;&gt;&gt;           prior to calling the policy chain?<br>
            Some candidates are:<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           * The encoding style<br>
                  &gt;&gt;&gt;&gt;           * All SOAP headers<br>
                  &gt;&gt;&gt;&gt;           * SOAPAction (already available as an<br>
            HTTP header)<br>
                  &gt;&gt;&gt;&gt;           * ???<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           For the soap headers, all of the<br>
            examples I&#39;ve seen<br>
                 take the<br>
                  &gt;&gt;&gt;&gt;           following<br>
                  &gt;&gt;&gt;&gt;           form:<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           &lt;HeaderName<br>
            xmlns=&quot;elementNS&quot;&gt;Header-Value&lt;/HeaderName&gt;<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           It can also have the optional &quot;actor&quot; or<br>
                 &quot;mustUnderstand&quot;<br>
                  &gt;&gt;&gt;&gt;           attributes.<br>
                  &gt;&gt;&gt;&gt;           The SOAP envelope schema is pretty lax<br>
            though, so<br>
                 I&#39;m not<br>
                  &gt;&gt;&gt;&gt;           sure if the<br>
                  &gt;&gt;&gt;&gt;           above is a convention or a rule.  Can<br>
            headers be more<br>
                  &gt;&gt;&gt;&gt;           complex than the<br>
                  &gt;&gt;&gt;&gt;           above?<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           -Eric<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           On 3/26/2016 7:06 AM, Benjamin Kastelic<br>
            wrote:<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;               Hi,<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;               I temporarily solved the problem by<br>
            storing the<br>
                 request<br>
                  &gt;&gt;&gt;&gt;               body, which is<br>
                  &gt;&gt;&gt;&gt;               contained in ApiRequest.rawRequest<br>
            object, in a<br>
                  &gt;&gt;&gt;&gt;               temporary buffer. I then<br>
                  &gt;&gt;&gt;&gt;               process the data (authentication)<br>
            and based on the<br>
                  &gt;&gt;&gt;&gt;               results proceed with<br>
                  &gt;&gt;&gt;&gt;               the policy chain or report a<br>
            failure. Then in<br>
                 the end()<br>
                  &gt;&gt;&gt;&gt;               method of the<br>
                  &gt;&gt;&gt;&gt;               requestDataHandler method I write<br>
            the contents of my<br>
                  &gt;&gt;&gt;&gt;               temporary buffer<br>
                  &gt;&gt;&gt;&gt;               using super.write(IApimanBuffer).<br>
            That way I can<br>
                 forward<br>
                  &gt;&gt;&gt;&gt;               the request to<br>
                  &gt;&gt;&gt;&gt;               then ext policy in the chain. But<br>
            this is still<br>
                 a hacky<br>
                  &gt;&gt;&gt;&gt;               way of doing<br>
                  &gt;&gt;&gt;&gt;               this.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;               I would be glad to help with<br>
            extending SOAP<br>
                 support. But<br>
                  &gt;&gt;&gt;&gt;               I would need a<br>
                  &gt;&gt;&gt;&gt;               few pointers where to start. The<br>
            way of storing SOAP<br>
                  &gt;&gt;&gt;&gt;               headers in the<br>
                  &gt;&gt;&gt;&gt;               ApiRequest object seems like a good<br>
            idea.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;               2016-03-24 18:40 GMT+01:00 Eric<br>
            Wittmann<br>
                  &gt;&gt;&gt;&gt;               &lt;<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;<br>
                  &gt;&gt;&gt;&gt; &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt;&lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;               &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;               &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;               &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;               &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;<br>
                 &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br>
            &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;&gt;&gt;&gt;&gt;:<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                   Hi Benjamin - thanks for the<br>
            excellent<br>
                 question.  I<br>
                  &gt;&gt;&gt;&gt;               will do my best<br>
                  &gt;&gt;&gt;&gt;                   to answer and note that I am<br>
            CC&#39;ing the<br>
                 apiman-dev<br>
                  &gt;&gt;&gt;&gt;               mailing list so<br>
                  &gt;&gt;&gt;&gt;                   others can chime in.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                   First let me say that a<br>
            WS-Security policy<br>
                 sounds<br>
                  &gt;&gt;&gt;&gt;               great - we haven&#39;t<br>
                  &gt;&gt;&gt;&gt;                   focused much on the WS-*<br>
            protocols because<br>
                 we get<br>
                  &gt;&gt;&gt;&gt;               much more demand<br>
                  &gt;&gt;&gt;&gt;                   for managing REST APIs than<br>
            SOAP APIs.  That<br>
                 said,<br>
                  &gt;&gt;&gt;&gt;               better SOAP<br>
                  &gt;&gt;&gt;&gt;                   support is certainly on the<br>
            radar.  When that<br>
                  &gt;&gt;&gt;&gt;               happens, my hope is<br>
                  &gt;&gt;&gt;&gt;                   that processing the envelope<br>
            might be a core<br>
                 part of<br>
                  &gt;&gt;&gt;&gt;               the gateway and<br>
                  &gt;&gt;&gt;&gt;                   so implementing policies that<br>
            use information in<br>
                  &gt;&gt;&gt;&gt;               there will be<br>
                  &gt;&gt;&gt;&gt;                   easier.  Perhaps your<br>
            implementation can be the<br>
                  &gt;&gt;&gt;&gt;               genesis of some of<br>
                  &gt;&gt;&gt;&gt;                   that work!<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                   To your question - without core<br>
            changes to<br>
                 apiman,<br>
                  &gt;&gt;&gt;&gt;               the approach you<br>
                  &gt;&gt;&gt;&gt;                   *need* to take is to have your<br>
            policy implement<br>
                  &gt;&gt;&gt;&gt;               IDataPolicy.  I<br>
                  &gt;&gt;&gt;&gt;                   believe you may have already<br>
            tried that, and<br>
                  &gt;&gt;&gt;&gt;               observed that you<br>
                  &gt;&gt;&gt;&gt;                   cannot send proper policy<br>
            failures from that<br>
                  &gt;&gt;&gt;&gt;               method.  You are right<br>
                  &gt;&gt;&gt;&gt;                   - that&#39;s something we will need<br>
            to fix!  I<br>
                 think you<br>
                  &gt;&gt;&gt;&gt;               should be able<br>
                  &gt;&gt;&gt;&gt;                   to throw a runtime exception<br>
            from the<br>
                  &gt;&gt;&gt;&gt;               write(IApimanBuffer chunk)<br>
                  &gt;&gt;&gt;&gt;                   method if you detect an error.<br>
            However,<br>
                 this is a<br>
                  &gt;&gt;&gt;&gt;               little bit hacky!<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                   Instead, I suggest (if you&#39;re<br>
            up for it) that we<br>
                  &gt;&gt;&gt;&gt;               perhaps work<br>
                  &gt;&gt;&gt;&gt;                   together to bake SOAP support<br>
            directly into<br>
                 the core<br>
                  &gt;&gt;&gt;&gt;               of apiman, such<br>
                  &gt;&gt;&gt;&gt;                   that the SOAP envelope is<br>
            read/parsed<br>
                 *before* the<br>
                  &gt;&gt;&gt;&gt;               policy chain is<br>
                  &gt;&gt;&gt;&gt;                   executed.  We could expose, for<br>
            example, the<br>
                 SOAP<br>
                  &gt;&gt;&gt;&gt;               headers as a<br>
                  &gt;&gt;&gt;&gt;                   proper Map&lt;&gt; stored either in<br>
            the context or<br>
                 on the<br>
                  &gt;&gt;&gt;&gt;               ApiRequest.<br>
                  &gt;&gt;&gt;&gt;                   This would allow you to<br>
            properly implement most<br>
                  &gt;&gt;&gt;&gt;               (all?) WS-*<br>
                  &gt;&gt;&gt;&gt;                   protocols as proper apiman<br>
            policies in the<br>
                  &gt;&gt;&gt;&gt;               apply(ApiRequest request)<br>
                  &gt;&gt;&gt;&gt;                   method.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                   Thoughts?<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                   -Eric<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                   On 3/24/2016 7:58 AM, Benjamin<br>
            Kastelic wrote:<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                       Greetings,<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                       I first thought to write<br>
            this question as an<br>
                  &gt;&gt;&gt;&gt;               issue on Github,<br>
                  &gt;&gt;&gt;&gt;               but it<br>
                  &gt;&gt;&gt;&gt;                       seemed better to write you<br>
            a direct email.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                       I am making a custom WS<br>
            Security policy,<br>
                 that<br>
                  &gt;&gt;&gt;&gt;               reads the body and<br>
                  &gt;&gt;&gt;&gt;                       check<br>
                  &gt;&gt;&gt;&gt;                       the UsernameToken security<br>
            header. This<br>
                 works<br>
                  &gt;&gt;&gt;&gt;               OK, but now I&#39;ve<br>
                  &gt;&gt;&gt;&gt;                       hit a wall.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                       In the doApply method I get<br>
            the rawRequest<br>
                  &gt;&gt;&gt;&gt;               object and read the<br>
                  &gt;&gt;&gt;&gt;                       body from<br>
                  &gt;&gt;&gt;&gt;                       the ServletInputStream of<br>
            the request. The<br>
                  &gt;&gt;&gt;&gt;               problem I&#39;m facing<br>
                  &gt;&gt;&gt;&gt;               now is<br>
                  &gt;&gt;&gt;&gt;                       that the input stream was<br>
            read and it<br>
                 can&#39;t be<br>
                  &gt;&gt;&gt;&gt;               reset back to it&#39;s<br>
                  &gt;&gt;&gt;&gt;                       initial state.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                       I was also trying to<br>
            implement the same<br>
                 logic<br>
                  &gt;&gt;&gt;&gt; in the<br>
                  &gt;&gt;&gt;&gt;                       requestDataHandler<br>
                  &gt;&gt;&gt;&gt;                       method, but I don&#39;t know if<br>
            it is even<br>
                 possible<br>
                  &gt;&gt;&gt;&gt;               to send a failure<br>
                  &gt;&gt;&gt;&gt;                       message to the request<br>
            chain from there.<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                       Any suggesstions ?<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;                       Best regards,<br>
                  &gt;&gt;&gt;&gt;                       Benjamin<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;               --<br>
                  &gt;&gt;&gt;&gt;               Lp, Benjamin<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;<br>
              _______________________________________________<br>
                  &gt;&gt;&gt;&gt;           Apiman-dev mailing list<br>
                  &gt;&gt;&gt;&gt; <a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a><br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a>&gt;<br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a><br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a>&gt;&gt;<br>
                 &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a><br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a>&gt;<br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a><br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a>&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a><br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a>&gt;<br>
                 &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a><br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a>&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a><br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a>&gt;<br>
                 &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a><br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a>&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;           &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a><br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a>&gt;<br>
                 &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a><br>
            &lt;mailto:<a href="mailto:Apiman-dev@lists.jboss.org" target="_blank">Apiman-dev@lists.jboss.org</a>&gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/apiman-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/apiman-dev</a><br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt;<br>
                  &gt;&gt;&gt;&gt; --<br>
                  &gt;&gt;&gt;&gt; Lp, Benjamin<br>
                  &gt;&gt;<br>
<br>
<br>
<br>
<br>
            --<br>
            Lp, Benjamin<br>
<br>
<br>
<br>
<br>
    --<br>
    Lp, Benjamin<br>
<br>
<br>
<br>
<br>
--<br>
Lp, Benjamin<br>
</div></div></blockquote>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Lp, Benjamin</div></div>
</div>