You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Anthony Fryer <ap...@hotmail.com> on 2013/08/26 15:22:24 UTC

WebServiceRef injection of CXF configured jax-ws client

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.

Re: WebServiceRef injection of CXF configured jax-ws client

Posted by Romain Manni-Bucau <rm...@gmail.com>.
No, you are right; @produces is better for the reason you mention
Le 26 août 2013 23:18, "Anthony Fryer" <ap...@hotmail.com> a écrit :

> It may be that I don't understand @WebServiceRef very well, but I don't see
> much value in using it in my case.  If I still have to programmatically
> configure endpoint address and security headers I think I might be better
> off using @Produces method to return a configured SEI.  Am I missing
> something about the @WebServiceRef annotation that is important?
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/WebServiceRef-injection-of-CXF-configured-jax-ws-client-tp4664824p4664840.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: WebServiceRef injection of CXF configured jax-ws client

Posted by Anthony Fryer <ap...@hotmail.com>.
It may be that I don't understand @WebServiceRef very well, but I don't see
much value in using it in my case.  If I still have to programmatically
configure endpoint address and security headers I think I might be better
off using @Produces method to return a configured SEI.  Am I missing
something about the @WebServiceRef annotation that is important?



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

Re: WebServiceRef injection of CXF configured jax-ws client

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

remote features means cxf module is activated that's why you need it.

About the config file it is not supported.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/8/26 Anthony Fryer <ap...@hotmail.com>

> 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.
>