I was wondering if it is possible to inject a cxf jax-ws client using the
@WebServiceRef annotation?  My scenario is that there is a web service that
is running in an external system that i want to call from a stateless ejb.  

I have run wsimport over the WSDL to generate the service
(@WebServiceClient) and port (@WebService) classes and packaged them up into
a jar file.

In my stateless ejb, i am using @WebServiceRef to inject a reference to the
generated service class.  This works ok if i want a standard reference
injected, but if i want to start configuring some things, like the endpoint
address or ws-security, i'm coding these things, which i don't want to do. 
I think there must be a way to configure cxf to do what i'm doing
programatically and have the @WebServiceRef inject a configured service
reference.


My ejb looks like this...

@Stateless
public class CreateLoyaltyAccountServiceImpl implements
CreateLoyaltyAccountService {
        
        @WebServiceRef
        
@HandlerChain(file="/META-INF/web-service/virgin/client-handler-chain.xml")
        MemberProfileMediatorService memberProfileService;
        
        MemberProfileMediatorPpt memberProfilePort;
        
        @PostConstruct
        private void postConstruct() {
                memberProfilePort =
memberProfileService.getMemberProfileMediatorServicePort();
                Map<String, Object> ctx =
((BindingProvider)memberProfilePort).getRequestContext();
                ctx.put("ws-security.username", "fffff");
                ctx.put("ws-security.password", "*****");
        }
}

You can see above i'm using postConstruct to do configure the ws-security of
the webservice interface.  Is it possible to have a cxf config file to do
this?  Something similar to below (with more properties than what i have
below to configure security and other things)...

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:jaxws="http://cxf.apache.org/jaxws";
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd";>
    
    <jaxws:client id="memberProfileService"
serviceClass="MemberProfileMediatorService"
                 
address="http://localhost:8080/MemberProfileMediatorService";
name="memberProfileService"/>
                  
</beans>

One other minor thing that i have noticed while unit testing in openejb, i
have to specify the openejb.embedded.remotable = true property for
@WebServiceRef to work, even though i'm not actually hosting any service
implementations, only the client references.  Why is it necessary to enable
remotable in this case?  I think it is initializing cxf perhaps?



--
View this message in context: 
http://openejb.979440.n4.nabble.com/WebServiceRef-injection-of-CXF-configured-jax-ws-client-tp4664824.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to