Johan Spaedtke
2013-07-31 09:25:25 UTC
I recently posted this question on Stck Overflow but haven't had any luck
with getting any answers so i thought I'd ask you guys aswell.
I'm currently writing a rather simple mule-flow that uses basic
authentication
<custom-transformer class="com.org.HttpRequestToMyRequest"
name="HttpRequestToMyRequest" doc:name="Java"/>
<flow name="Input_Flow" doc:name="Input_Flow">
<http:inbound-endpoint exchange-pattern="request-response"
host="http://12.23.34.45" port="1234" path="/foo">
<mule-ss:http-security-filter realm="mule-realm"/>
</http:inbound-endpoint>
<flow-ref name="Sorting_Flow" doc:name="Sorting flow"/>
</flow>
<sub-flow name="Sorting_Flow" doc:name="Sorting_Flow">
<transformer ref="HttpRequestToMyRequest" doc:name="Transform Http
Request to POJO with interesting methods"/>
<enricher target="#[variable:authorized]">
<http:outbound-endpoint exchange-pattern="request-response"
host="12.34.45.56" port="1234" path="foo/bar" method="GET"
disableTransportTransformer="true"
responseTransformer-refs="ObjectToString"
doc:name="Authorization Service"/>
</enricher>
<choice doc:name="Choice">
<when expression="header:INVOCATION:authorized=true">
<processor-chain>
<component class="com.org.MyClass"/>
<transformer ref="MyObjToString"/>
<http:response-builder status="200"
contentType="text/xml" doc:name="HTTP Response Builder"/>
</processor-chain>
</when>
<when SOMETHING ELSE>
DO SOMETHING ELSE
</when>
</choice>
</sub-flow>
If I remove the http-security-filter then this flow works as expected and
the payload in the MuleMessage is of the type MyRequest returned by the
HttpRequestToMyRequest transformer. But once i add the security-filter the
enricher changes my payload from the expected type to a byte[]. If i
convert the byte[] to a String then it turns out to be the instancename of
MyRequest (***@15ae9009).
Just to be clear. Here are three flow xml fragments where two behave well
and the last one has the strange behaviour i don't understand.
This flow, where I've commented out the security-filter on the inbound
endpoint, works as expected and the ClassNameLogger statements prints out,
in order, String, MyRequest, MyRequest.
<custom-transformer class="com.org.HttpRequestToMyRequest"
name="HttpRequestToMyRequest" doc:name="Java"/>
<custom-transformer class="com.org.ClassNameLogger"
name="ClassNameLogger" doc:name="Java"/>
<flow name="Input_Flow" doc:name="Input_Flow">
<http:inbound-endpoint exchange-pattern="request-response"
host="http://12.23.34.45" port="1234" path="/foo">
<!-- <mule-ss:http-security-filter realm="mule-realm"/> -->
</http:inbound-endpoint>
<flow-ref name="Sorting_Flow" doc:name="Sorting flow"/>
</flow>
<sub-flow name="Sorting_Flow" doc:name="Sorting_Flow">
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<transformer ref="HttpRequestToMyRequest" doc:name="Transform Http
Request to POJO with interesting methods"/>
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<enricher target="#[variable:authorized]">
<http:outbound-endpoint exchange-pattern="request-response"
host="12.34.45.56" port="1234" path="foo/bar" method="GET"
disableTransportTransformer="true"
responseTransformer-refs="ObjectToString"
doc:name="Authorization Service"/>
</enricher>
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<choice doc:name="Choice">
<when expression="header:INVOCATION:authorized=true">
<processor-chain>
<component class="com.org.MyClass"/>
<transformer ref="MyObjToString"/>
<http:response-builder status="200"
contentType="text/xml" doc:name="HTTP Response Builder"/>
</processor-chain>
</when>
<when SOMETHING ELSE>
DO SOMETHING ELSE
</when>
</choice>
</sub-flow>
This flow, where I've commented out the enricher, works as expected, aside
from the fact that it doesn't enter the choise since the variable set by
the enricher is not defined. The ClassNameLogger statements prints out, in
order, String, MyRequest, MyRequest.
<custom-transformer class="com.org.HttpRequestToMyRequest"
name="HttpRequestToMyRequest" doc:name="Java"/>
<custom-transformer class="com.org.ClassNameLogger"
name="ClassNameLogger" doc:name="Java"/>
<flow name="Input_Flow" doc:name="Input_Flow">
<http:inbound-endpoint exchange-pattern="request-response"
host="http://12.23.34.45" port="1234" path="/foo">
<mule-ss:http-security-filter realm="mule-realm"/>
</http:inbound-endpoint>
<flow-ref name="Sorting_Flow" doc:name="Sorting flow"/>
</flow>
<sub-flow name="Sorting_Flow" doc:name="Sorting_Flow">
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<transformer ref="HttpRequestToMyRequest" doc:name="Transform Http
Request to POJO with interesting methods"/>
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<!-- <enricher target="#[variable:authorized]">
<http:outbound-endpoint exchange-pattern="request-response"
host="12.34.45.56" port="1234" path="foo/bar" method="GET"
disableTransportTransformer="true"
responseTransformer-refs="ObjectToString"
doc:name="Authorization Service"/>
</enricher> -->
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<choice doc:name="Choice">
<when expression="header:INVOCATION:authorized=true">
<processor-chain>
<component class="com.org.MyClass"/>
<transformer ref="MyObjToString"/>
<http:response-builder status="200"
contentType="text/xml" doc:name="HTTP Response Builder"/>
</processor-chain>
</when>
<when SOMETHING ELSE>
DO SOMETHING ELSE
</when>
</choice>
</sub-flow>
This flow, where I have both the enricher and the security-filter in place,
doesn't work as expected and the ClassNameLogger statements prints out, in
order, String, MyRequest, byte[].
<custom-transformer class="com.org.HttpRequestToMyRequest"
name="HttpRequestToMyRequest" doc:name="Java"/>
<custom-transformer class="com.org.ClassNameLogger"
name="ClassNameLogger" doc:name="Java"/>
<flow name="Input_Flow" doc:name="Input_Flow">
<http:inbound-endpoint exchange-pattern="request-response"
host="http://12.23.34.45" port="1234" path="/foo">
<mule-ss:http-security-filter realm="mule-realm"/>
</http:inbound-endpoint>
<flow-ref name="Sorting_Flow" doc:name="Sorting flow"/>
</flow>
<sub-flow name="Sorting_Flow" doc:name="Sorting_Flow">
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<transformer ref="HttpRequestToMyRequest" doc:name="Transform Http
Request to POJO with interesting methods"/>
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<enricher target="#[variable:authorized]">
<http:outbound-endpoint exchange-pattern="request-response"
host="12.34.45.56" port="1234" path="foo/bar" method="GET"
disableTransportTransformer="true"
responseTransformer-refs="ObjectToString"
doc:name="Authorization Service"/>
</enricher>
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<choice doc:name="Choice">
<when expression="header:INVOCATION:authorized=true">
<processor-chain>
<component class="com.org.MyClass"/>
<transformer ref="MyObjToString"/>
<http:response-builder status="200"
contentType="text/xml" doc:name="HTTP Response Builder"/>
</processor-chain>
</when>
<when SOMETHING ELSE>
DO SOMETHING ELSE
</when>
</choice>
</sub-flow>
Any help or ideas would be appreciated.
I'm using Mule 3.3 since I don't have permissions to upgrade at the moment
and I'm rather new to Mule so all pointers regarding unnecessarily
complicated syntax or weird constructs are also greatly appreciated :)
Regards
//Johan
with getting any answers so i thought I'd ask you guys aswell.
I'm currently writing a rather simple mule-flow that uses basic
authentication
<custom-transformer class="com.org.HttpRequestToMyRequest"
name="HttpRequestToMyRequest" doc:name="Java"/>
<flow name="Input_Flow" doc:name="Input_Flow">
<http:inbound-endpoint exchange-pattern="request-response"
host="http://12.23.34.45" port="1234" path="/foo">
<mule-ss:http-security-filter realm="mule-realm"/>
</http:inbound-endpoint>
<flow-ref name="Sorting_Flow" doc:name="Sorting flow"/>
</flow>
<sub-flow name="Sorting_Flow" doc:name="Sorting_Flow">
<transformer ref="HttpRequestToMyRequest" doc:name="Transform Http
Request to POJO with interesting methods"/>
<enricher target="#[variable:authorized]">
<http:outbound-endpoint exchange-pattern="request-response"
host="12.34.45.56" port="1234" path="foo/bar" method="GET"
disableTransportTransformer="true"
responseTransformer-refs="ObjectToString"
doc:name="Authorization Service"/>
</enricher>
<choice doc:name="Choice">
<when expression="header:INVOCATION:authorized=true">
<processor-chain>
<component class="com.org.MyClass"/>
<transformer ref="MyObjToString"/>
<http:response-builder status="200"
contentType="text/xml" doc:name="HTTP Response Builder"/>
</processor-chain>
</when>
<when SOMETHING ELSE>
DO SOMETHING ELSE
</when>
</choice>
</sub-flow>
If I remove the http-security-filter then this flow works as expected and
the payload in the MuleMessage is of the type MyRequest returned by the
HttpRequestToMyRequest transformer. But once i add the security-filter the
enricher changes my payload from the expected type to a byte[]. If i
convert the byte[] to a String then it turns out to be the instancename of
MyRequest (***@15ae9009).
Just to be clear. Here are three flow xml fragments where two behave well
and the last one has the strange behaviour i don't understand.
This flow, where I've commented out the security-filter on the inbound
endpoint, works as expected and the ClassNameLogger statements prints out,
in order, String, MyRequest, MyRequest.
<custom-transformer class="com.org.HttpRequestToMyRequest"
name="HttpRequestToMyRequest" doc:name="Java"/>
<custom-transformer class="com.org.ClassNameLogger"
name="ClassNameLogger" doc:name="Java"/>
<flow name="Input_Flow" doc:name="Input_Flow">
<http:inbound-endpoint exchange-pattern="request-response"
host="http://12.23.34.45" port="1234" path="/foo">
<!-- <mule-ss:http-security-filter realm="mule-realm"/> -->
</http:inbound-endpoint>
<flow-ref name="Sorting_Flow" doc:name="Sorting flow"/>
</flow>
<sub-flow name="Sorting_Flow" doc:name="Sorting_Flow">
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<transformer ref="HttpRequestToMyRequest" doc:name="Transform Http
Request to POJO with interesting methods"/>
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<enricher target="#[variable:authorized]">
<http:outbound-endpoint exchange-pattern="request-response"
host="12.34.45.56" port="1234" path="foo/bar" method="GET"
disableTransportTransformer="true"
responseTransformer-refs="ObjectToString"
doc:name="Authorization Service"/>
</enricher>
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<choice doc:name="Choice">
<when expression="header:INVOCATION:authorized=true">
<processor-chain>
<component class="com.org.MyClass"/>
<transformer ref="MyObjToString"/>
<http:response-builder status="200"
contentType="text/xml" doc:name="HTTP Response Builder"/>
</processor-chain>
</when>
<when SOMETHING ELSE>
DO SOMETHING ELSE
</when>
</choice>
</sub-flow>
This flow, where I've commented out the enricher, works as expected, aside
from the fact that it doesn't enter the choise since the variable set by
the enricher is not defined. The ClassNameLogger statements prints out, in
order, String, MyRequest, MyRequest.
<custom-transformer class="com.org.HttpRequestToMyRequest"
name="HttpRequestToMyRequest" doc:name="Java"/>
<custom-transformer class="com.org.ClassNameLogger"
name="ClassNameLogger" doc:name="Java"/>
<flow name="Input_Flow" doc:name="Input_Flow">
<http:inbound-endpoint exchange-pattern="request-response"
host="http://12.23.34.45" port="1234" path="/foo">
<mule-ss:http-security-filter realm="mule-realm"/>
</http:inbound-endpoint>
<flow-ref name="Sorting_Flow" doc:name="Sorting flow"/>
</flow>
<sub-flow name="Sorting_Flow" doc:name="Sorting_Flow">
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<transformer ref="HttpRequestToMyRequest" doc:name="Transform Http
Request to POJO with interesting methods"/>
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<!-- <enricher target="#[variable:authorized]">
<http:outbound-endpoint exchange-pattern="request-response"
host="12.34.45.56" port="1234" path="foo/bar" method="GET"
disableTransportTransformer="true"
responseTransformer-refs="ObjectToString"
doc:name="Authorization Service"/>
</enricher> -->
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<choice doc:name="Choice">
<when expression="header:INVOCATION:authorized=true">
<processor-chain>
<component class="com.org.MyClass"/>
<transformer ref="MyObjToString"/>
<http:response-builder status="200"
contentType="text/xml" doc:name="HTTP Response Builder"/>
</processor-chain>
</when>
<when SOMETHING ELSE>
DO SOMETHING ELSE
</when>
</choice>
</sub-flow>
This flow, where I have both the enricher and the security-filter in place,
doesn't work as expected and the ClassNameLogger statements prints out, in
order, String, MyRequest, byte[].
<custom-transformer class="com.org.HttpRequestToMyRequest"
name="HttpRequestToMyRequest" doc:name="Java"/>
<custom-transformer class="com.org.ClassNameLogger"
name="ClassNameLogger" doc:name="Java"/>
<flow name="Input_Flow" doc:name="Input_Flow">
<http:inbound-endpoint exchange-pattern="request-response"
host="http://12.23.34.45" port="1234" path="/foo">
<mule-ss:http-security-filter realm="mule-realm"/>
</http:inbound-endpoint>
<flow-ref name="Sorting_Flow" doc:name="Sorting flow"/>
</flow>
<sub-flow name="Sorting_Flow" doc:name="Sorting_Flow">
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<transformer ref="HttpRequestToMyRequest" doc:name="Transform Http
Request to POJO with interesting methods"/>
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<enricher target="#[variable:authorized]">
<http:outbound-endpoint exchange-pattern="request-response"
host="12.34.45.56" port="1234" path="foo/bar" method="GET"
disableTransportTransformer="true"
responseTransformer-refs="ObjectToString"
doc:name="Authorization Service"/>
</enricher>
<transformer ref="ClassNameLogger" doc:name="Logs The Class Name of
MuleMessage payload"/>
<choice doc:name="Choice">
<when expression="header:INVOCATION:authorized=true">
<processor-chain>
<component class="com.org.MyClass"/>
<transformer ref="MyObjToString"/>
<http:response-builder status="200"
contentType="text/xml" doc:name="HTTP Response Builder"/>
</processor-chain>
</when>
<when SOMETHING ELSE>
DO SOMETHING ELSE
</when>
</choice>
</sub-flow>
Any help or ideas would be appreciated.
I'm using Mule 3.3 since I don't have permissions to upgrade at the moment
and I'm rather new to Mule so all pointers regarding unnecessarily
complicated syntax or weird constructs are also greatly appreciated :)
Regards
//Johan
--
RF kap. 2 §6 Varje medborgare är gentemot det allmänna skyddad mot
påtvingat kroppsligt ingrepp även i annat fall än som avses i 4 och 5 §§.
Han är därjämte skyddad mot kroppsvisitation, husrannsakan och liknande
intrång samt mot undersökning av brev eller annan förtrolig försändelse och
mot hemlig avlyssning eller upptagning av telefonsamtal eller annat
förtroligt meddelande. Lag (1976:871).
RF kap. 2 §6 Varje medborgare är gentemot det allmänna skyddad mot
påtvingat kroppsligt ingrepp även i annat fall än som avses i 4 och 5 §§.
Han är därjämte skyddad mot kroppsvisitation, husrannsakan och liknande
intrång samt mot undersökning av brev eller annan förtrolig försändelse och
mot hemlig avlyssning eller upptagning av telefonsamtal eller annat
förtroligt meddelande. Lag (1976:871).