You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by psd <pr...@thomsonreuters.com> on 2015/02/19 10:46:33 UTC
Properties defined on Bus are not available on Endpoints
Hi,
I have many endpoints defined in my spring config & I needed to apply some
properties on each one of them, so I put them on bus, but it seems those
defined on bus are not available for some reason to the endpoints.
Here is my Bus configuration:
<cxf:bus>
<cxf:properties>
<entry key="ws-security.enable.nonce.cache" value="false"/>
</cxf:properties>
</cxf:bus>
& here is one of the endpoint that I was testing:
<jaxws:endpoint implementor="#ontServiceEntryPoint"
address="local://ontSoap" >
<jaxws:inInterceptors>
<ref bean="ApiTokenSoapInterceptor" />
<ref bean="wss4jInterceptor" />
<ref bean="ApiContextSoapInterceptor" />
</jaxws:inInterceptors>
<jaxws:outFaultInterceptors>
<ref bean="ApiServiceOutFaultInterceptor" />
</jaxws:outFaultInterceptors>
</jaxws:endpoint>
I have to put
<jaxws:properties>
<entry key="ws-security.enable.nonce.cache" value="false"/>
</jaxws:properties>
to make it work in endpoint.
Am I understanding it wrong way that properties defined on bus will by
default be available to all endpoints?
I'm using cxf version 3.0.2 (also tried same on latest 3.0.4) with WSS4j
2.0.2 (2.0.3 for cxf 3.0.4)
Thanks,
psd
--
View this message in context: http://cxf.547215.n5.nabble.com/Properties-defined-on-Bus-are-not-available-on-Endpoints-tp5754469.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Properties defined on Bus are not available on Endpoints
Posted by Sergey Beryozkin <sb...@gmail.com>.
I have the following in one of the tests [1]:
<core:bus name="cxf1" id="cxf1"/>
<jaxrs:server bus="cxf1" address="/genericstore">
I've just modified it as follows:
<core:bus>
<core:properties>
<entry key="a" value="false"/>
</core:properties>
</core:bus>
<jaxrs:server address="/genericstore">
and then updated the endpoint code to:
@GET
@Path("/books/superbooks2")
public GenericEntity<List<T>> getSuperBookCollectionGenericEntity() {
System.out.println(JAXRSUtils.getCurrentMessage().getContextualProperty("a"));
//...
}
it prints 'false' as expected when the endpoint is invoked.
Sergey
[1]
https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=systests/jaxrs/src/test/resources/jaxrs_jackson_provider/WEB-INF/beans.xml;h=bafb0e6b7dc6a496f56d9aec867319b9d3894b7e;hb=HEAD#l53
On 20/02/15 10:45, psd wrote:
> Hi Sergey,
>
> Thanks for tip, I was indeed poking around same classes as you suggested.
> Found out that for some reason, spring is creating & setting Bus at
> endpoint.
>
> Then I tried defining & overriding bean definition as follows:
>
> <bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus"
> destroy-method="shutdown" scope="singleton">
> <property name="properties">
> <map>
> <entry key="ws-security.enable.nonce.cache" value="false"/>
> </map>
> </property>
> </bean>
>
> still no luck.
>
> I also tried referencing endpoint with above bus: <jaxws:endpoint bus="cxf"
> .......... >
>
> looks like I'm running out of luck...
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Properties-defined-on-Bus-are-not-available-on-Endpoints-tp5754469p5754495.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
Re: Properties defined on Bus are not available on Endpoints
Posted by psd <pr...@thomsonreuters.com>.
Hi Sergey,
Thanks for tip, I was indeed poking around same classes as you suggested.
Found out that for some reason, spring is creating & setting Bus at
endpoint.
Then I tried defining & overriding bean definition as follows:
<bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus"
destroy-method="shutdown" scope="singleton">
<property name="properties">
<map>
<entry key="ws-security.enable.nonce.cache" value="false"/>
</map>
</property>
</bean>
still no luck.
I also tried referencing endpoint with above bus: <jaxws:endpoint bus="cxf"
.......... >
looks like I'm running out of luck...
--
View this message in context: http://cxf.547215.n5.nabble.com/Properties-defined-on-Bus-are-not-available-on-Endpoints-tp5754469p5754495.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Properties defined on Bus are not available on Endpoints
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Prasad
What I meant was to put a breakpoint in Message.getContextProperties -
these are the properties relevant to a given invocation and they have
the properties from the endpoint specific bus accumulated.
So start from:
https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JUtils.java;h=0e891e605b6bce2bb1bcd547aa86a3d62ec422d4;hb=HEAD#l81
This is where the property is checked. The Message property cache has
already been prepared by then, so you can start earlier and put a
breakpoint in:
https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=core/src/main/java/org/apache/cxf/message/MessageImpl.java;h=b08b0c5f9dd525fa954f6b5d47c5c2863c1e3427;hb=HEAD#l174
There you will see the bus properties being added to the current cache.
If a given bus has no the expected properties then as I suggested you'd
need to isolate the problem by starting from the simplest case where the
properties are available and then proceeding to incrementally updating
the configuration (as per your case) until it breaks - this will help to
figure out where the problem actually is
HTH
Sergey
On 19/02/15 16:42, psd wrote:
> Hi Sergey,
>
> Following your instructions, it really proving really difficult for me to
> setup things with non-local transport..
> could you please be able to let me know where did you see bus properties are
> being checked?
>
> I can see that Exchange properties are being copied in
> ChainInitiationObserver.setExchangeProperties() method... but I couldn't
> find same for Bus.. in fact the default bus ?
>
> Thanks,
> psd
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Properties-defined-on-Bus-are-not-available-on-Endpoints-tp5754469p5754484.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
Re: Properties defined on Bus are not available on Endpoints
Posted by psd <pr...@thomsonreuters.com>.
Hi Sergey,
Following your instructions, it really proving really difficult for me to
setup things with non-local transport..
could you please be able to let me know where did you see bus properties are
being checked?
I can see that Exchange properties are being copied in
ChainInitiationObserver.setExchangeProperties() method... but I couldn't
find same for Bus.. in fact the default bus ?
Thanks,
psd
--
View this message in context: http://cxf.547215.n5.nabble.com/Properties-defined-on-Bus-are-not-available-on-Endpoints-tp5754469p5754484.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Properties defined on Bus are not available on Endpoints
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 19/02/15 12:48, psd wrote:
> Sergey Beryozkin wrote
>> It appears a bus allocated to the endpoint is different to the one where
>> the properties are set. If yes - you can have the endpoint linked to a
>> specific bus id
>
> Hi Sergey,
>
> Thanks for quick response, yes, that indeed seems to be the case, bus
> allocated to endpoint is different than the one that has properties defined.
>
> However, I thought if I define it with
> <cxf:bus>
> <cxf:properties>
> <entry key="ws-security.enable.nonce.cache" value="false"/>
> </cxf:properties>
> </cxf:bus>
>
> that should be the default bus & I shouldn't need to define bus on every
> endpoint. Am I wrong in assuming?
I think you are right. I'm not sure though why this bus defined in the
context is not set as a default bus.
Can you please do an experiment: Have a single Spring context only,
single cxf:bus in that context and a single endpoint (with a non-local
transport). That should work as expected as far as the visibility of bus
properties are concerned. Then narrow it down to next configuration
where it breaks.
Let us know please what you observe
Thanks, Sergey
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Properties-defined-on-Bus-are-not-available-on-Endpoints-tp5754469p5754476.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
Re: Properties defined on Bus are not available on Endpoints
Posted by psd <pr...@thomsonreuters.com>.
Sergey Beryozkin wrote
> It appears a bus allocated to the endpoint is different to the one where
> the properties are set. If yes - you can have the endpoint linked to a
> specific bus id
Hi Sergey,
Thanks for quick response, yes, that indeed seems to be the case, bus
allocated to endpoint is different than the one that has properties defined.
However, I thought if I define it with
<cxf:bus>
<cxf:properties>
<entry key="ws-security.enable.nonce.cache" value="false"/>
</cxf:properties>
</cxf:bus>
that should be the default bus & I shouldn't need to define bus on every
endpoint. Am I wrong in assuming?
--
View this message in context: http://cxf.547215.n5.nabble.com/Properties-defined-on-Bus-are-not-available-on-Endpoints-tp5754469p5754476.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Properties defined on Bus are not available on Endpoints
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Prasad
Thanks for asking this question on the users list.
Typically the CXF code would use
Message.getContextualProperty(propertyName)
to check if a property has been set. I've looked at the code, the bus
properties are being checked too.
You asked where it can be debugged, so I guess the best bet is to a
breakpoint in Message.getContextualProperty but I guess only after the
call reaches WSS4JInterceptor.
It appears a bus allocated to the endpoint is different to the one where
the properties are set. If yes - you can have the endpoint linked to a
specific bus id
Cheers, Sergey
On 19/02/15 09:46, psd wrote:
> Hi,
>
> I have many endpoints defined in my spring config & I needed to apply some
> properties on each one of them, so I put them on bus, but it seems those
> defined on bus are not available for some reason to the endpoints.
>
> Here is my Bus configuration:
> <cxf:bus>
> <cxf:properties>
> <entry key="ws-security.enable.nonce.cache" value="false"/>
> </cxf:properties>
> </cxf:bus>
>
> & here is one of the endpoint that I was testing:
>
> <jaxws:endpoint implementor="#ontServiceEntryPoint"
> address="local://ontSoap" >
> <jaxws:inInterceptors>
> <ref bean="ApiTokenSoapInterceptor" />
> <ref bean="wss4jInterceptor" />
> <ref bean="ApiContextSoapInterceptor" />
> </jaxws:inInterceptors>
> <jaxws:outFaultInterceptors>
> <ref bean="ApiServiceOutFaultInterceptor" />
> </jaxws:outFaultInterceptors>
> </jaxws:endpoint>
>
> I have to put
> <jaxws:properties>
> <entry key="ws-security.enable.nonce.cache" value="false"/>
> </jaxws:properties>
> to make it work in endpoint.
>
> Am I understanding it wrong way that properties defined on bus will by
> default be available to all endpoints?
>
> I'm using cxf version 3.0.2 (also tried same on latest 3.0.4) with WSS4j
> 2.0.2 (2.0.3 for cxf 3.0.4)
>
> Thanks,
> psd
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Properties-defined-on-Bus-are-not-available-on-Endpoints-tp5754469.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>