Hi Stefan,
Ok, I get your point.
You just need inject a NMR which is an osgi service into your MyBean
so the configuration looks like
<jaxws:endpoint
id="helloWorld"
implementor="#mybean"
address="http://localhost/HelloWorld">
<jaxws:properties>
<entry key="mtom-enabled" value="true"/>
</jaxws:properties>
</jaxws:endpoint>
<osgi:reference id="nmr"
interface="org.apache.servicemix.nmr.api.NMR"
cardinality="1..1" />
<bean id="mybean" class="org.dummy.MyBean">
<property name="nmr" ref="nmr" />
</bean>
And you need add method like
public void setNmr(NMR nmr) {
this.nmr = nmr;
}
in your MyBean.
then in your MyBean handling method, use the nmr like
Channel client = null;
try {
// Create the client channel
client = nmr.createChannel();
// Create a reference that will be used as the target for
our exchanges
Reference ref =
nmr.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME,
"YourEndpointYouWantToSendME"));
try {
// Create an exchange and send it
Exchange e = client.createExchange(Pattern.InOut);
e.setTarget(ref);
e.getIn().setBody("whateveryouwant");
client.sendSync(e);
LOG.info("Response from Endpoint " +
e.getOut().getBody());
// Send back the Done status
e.setStatus(Status.Done);
client.send(e);
} catch (Exception e) {
e.printStackTrace();
LOG.error(e.getMessage());
}
Freeman
Stefan Weber wrote:
Hi,
i have to admit that i'm really confused. I had a look at the cxf-nmr
example and also deployed it (the original version and a modified one) but
there is no nmr endpoint registered and no webservice started as well. Did i
missed something? A bit clarification would be nice :)
What i want to do:
- register a webservice
- handle the ws calls
- dispatch messages/exchanges to the nmr within the handling method
The only problem is, how do i get the DeliveryChannel/ComponentContext
inside my bean.
Thanks in advance
Regards
Stefan
Stefan Weber wrote:
Hi,
because CXF is not working properly (see
http://www.nabble.com/SMX-CXF-BC-crazy-nondeterministic-behavior%3A-org.apache.cxf.BusException-to23778867.html)
i'm trying to use jaxws for my webservice.
But now i ran into the issue that the ComponentContext cant be injected
into the jaxws bean. However i need it for sending messages into the nmr.
Am i right with this assumption?!
I use the OSGI deployment in smx4. Config is similar to this:
<jaxws:endpoint
id="helloWorld"
implementor="#mybean"
address="http://localhost/HelloWorld">
<jaxws:properties>
<entry key="mtom-enabled" value="true"/>
</jaxws:properties>
</jaxws:endpoint>
<bean id="mybean" class="org.dummy.MyBean"/>
Injecting the jaxws endpoint into the bean ends up in a circular reference
thus an exception.
Any hint would be nice.
Regards
Stefan
--
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com