You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jeppe Cramon <xj...@dsb.dk> on 2012/01/19 15:06:24 UTC
WS-Policy jaxws-client defined in Spring using createdFromAPI - problem under JBoss 6
Hi
Thanks to previous help on this message list we've managed to create a
jax-ws client against an Oracle Service Bus endpoint which uses
WS-Security/WS-Policy
.
The problem is that everything works fine in pure Java (test) and under
Jetty & Tomcat. However for real use I need to deploy it under JBoss 6
AS.
However the CXF version Jboss 6 AS comes with (2.3.1) doesn't work
(fails early with a NPE during policy initialization). So after reading
up on it, I followed the suggested solution which is to install
JBossWS-Native under JBoss 6 and then bundle our own CXF (version 2.5.1)
with the WAR file.
This works nicely for all other service clients, except for the ONLY one
that's done using createdFromAPI=true - the problem occurs because we
need to instantiate it using Service.getPort()(mostly since I don't know
of other ways to create the Jaxws instance from within Spring for this
createdFromAPI case) ...
--->When we do this, JBoss-WS Native then takes over a JAX-WS Provider
and then it wont work :-/
The question is - how do it create my jaxws client so I can call the
secured endpoint (ie. Still use createdFromAPI) and still run the thing
under JBoss 6?
Here's how I've done it so far:
The definition is done in Spring (after an example I found):
<cxf:bus>
<cxf:features>
<p:policies />
<cxf:logging />
</cxf:features>
</cxf:bus>
<jaxws:client
name="{http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
ventModtagerService}PrivatKundeEventModtagerServiceBindingQSPort"
createdFromAPI="true">
<jaxws:properties>
<entry key="ws-security.callback-handler"
value="dk.dsb.ic.kundekerne.security.ClientKeystorePasswordCallback" />
<entry key="ws-security.encryption.properties"
value="security/clientKeystore.properties" />
<entry key="ws-security.encryption.username"
value="osb-public" />
<entry key="ws-security.signature.properties"
value="security/clientKeystore.properties" />
<entry key="ws-security.signature.username"
value="kundekerne" />
</jaxws:properties>
<jaxws:handlers>
<bean
class="dk.dsb.ic.kundekerne.OutgoingIgpClientIgpHeaderHandler"/>
</jaxws:handlers>
</jaxws:client>
And from within the Java code I do the following:
String endpoint =
"http://testserver:8200/KundeKerneInternOutbound/PrivatKundeEventModtage
rServicePS";
URL wsdl = new URL(endpoint + "?wsdl");
Service service = Service.create(wsdl, new
QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
ventModtagerService",
"PrivatKundeEventModtagerServiceBindingQSService"));
QName portQName = new
QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
ventModtagerService", "PrivatKundeEventModtagerServiceBindingQSPort");
PrivatKundeEventModtagerServicePortType x509Port =
service.getPort(portQName,
PrivatKundeEventModtagerServicePortType.class);
return x509Port;
Thanks in advance
/Jeppe
Re: SV: WS-Policy jaxws-client defined in Spring using createdFromAPI - problem under JBoss 6
Posted by Daniel Kulp <dk...@apache.org>.
On Friday, January 20, 2012 2:09:16 PM Jeppe Cramon wrote:
> Hi
>
> A small update for those who looked at the original mail.
>
> I ended up hacking a solution which is ugly but works.
> If others have a better suggestions I'm all ears :)
>
Since you are tied to CXF anyway, you could likely try using the
JaxWsClientFactoryBean directly to create the proxy. I believe that would
work in this case. Set the service name, endpoint name, etc... on the
JaxWsClientFactoryBean and call create.
Dan
> If it's the "best" solution, then perhaps others in the same situation
> can be helped in the future by seeing the hack.
>
> // Point to a WS-Policy less contract
> // The reason is that JBossWS-native can't handle parsing the WS-Policy
> enabled contract
> Service service =
> Service.create(this.getClass().getResource("kundekerne/intern/events/udh
> entning/PrivatKundeEventUdhentningsService/PrivatKundeEventUdhentningsSe
> rvice.wsdl"), new
> QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
> ventModtagerService", "PrivatKundeEventModtagerService"));
>
> // WSDL endpoint which points to the WS-Policy enabled contract
> String endpoint = getEndPointUrl();
> URL wsdl = new URL(endpoint + "?wsdl");
> QName serviceQName = new
> QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
> ventModtagerService",
> "PrivatKundeEventModtagerServiceBindingQSService");
>
> // Access the Service delegate field and override its value (change from
> JBossWS-Native to CXF)
> Field delegateField = ReflectUtils.getField(Service.class, "delegate");
> ReflectUtils.makeAccessible(delegateField);
> // Override the value
> ReflectUtils.setFieldValue(delegateField, service, new
> ProviderImpl().createServiceDelegate(wsdl, serviceQName,
> Service.class));
>
> // Get the port
> QName portQName = new
> QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
> ventModtagerService", "PrivatKundeEventModtagerServiceBindingQSPort");
> return service.getPort(portQName,
> PrivatKundeEventModtagerServicePortType.class);
>
> /Jeppe
>
> -----Oprindelig meddelelse-----
> Fra: Jeppe Cramon [mailto:xjecr@dsb.dk]
> Sendt: 19. januar 2012 15:06
> Til: users@cxf.apache.org
> Emne: WS-Policy jaxws-client defined in Spring using createdFromAPI -
> problem under JBoss 6
>
> Hi
>
>
>
> Thanks to previous help on this message list we've managed to create a
> jax-ws client against an Oracle Service Bus endpoint which uses
> WS-Security/WS-Policy
>
> .
>
> The problem is that everything works fine in pure Java (test) and under
> Jetty & Tomcat. However for real use I need to deploy it under JBoss 6
> AS.
>
>
>
> However the CXF version Jboss 6 AS comes with (2.3.1) doesn't work
> (fails early with a NPE during policy initialization). So after reading
> up on it, I followed the suggested solution which is to install
> JBossWS-Native under JBoss 6 and then bundle our own CXF (version 2.5.1)
> with the WAR file.
>
> This works nicely for all other service clients, except for the ONLY one
> that's done using createdFromAPI=true - the problem occurs because we
> need to instantiate it using Service.getPort()(mostly since I don't know
> of other ways to create the Jaxws instance from within Spring for this
> createdFromAPI case) ...
>
>
>
> --->When we do this, JBoss-WS Native then takes over a JAX-WS Provider
> and then it wont work :-/
>
> The question is - how do it create my jaxws client so I can call the
> secured endpoint (ie. Still use createdFromAPI) and still run the thing
> under JBoss 6?
>
>
>
> Here's how I've done it so far:
>
>
>
> The definition is done in Spring (after an example I found):
>
>
>
> <cxf:bus>
>
> <cxf:features>
>
> <p:policies />
>
> <cxf:logging />
>
> </cxf:features>
>
> </cxf:bus>
>
>
>
> <jaxws:client
> name="{http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
> ventModtagerService}PrivatKundeEventModtagerServiceBindingQSPort"
>
> createdFromAPI="true">
>
> <jaxws:properties>
>
> <entry key="ws-security.callback-handler"
>
>
> value="dk.dsb.ic.kundekerne.security.ClientKeystorePasswordCallback" />
>
> <entry key="ws-security.encryption.properties"
> value="security/clientKeystore.properties" />
>
> <entry key="ws-security.encryption.username"
> value="osb-public" />
>
> <entry key="ws-security.signature.properties"
> value="security/clientKeystore.properties" />
>
> <entry key="ws-security.signature.username"
> value="kundekerne" />
>
> </jaxws:properties>
>
> <jaxws:handlers>
>
> <bean
> class="dk.dsb.ic.kundekerne.OutgoingIgpClientIgpHeaderHandler"/>
>
> </jaxws:handlers>
>
> </jaxws:client>
>
>
>
> And from within the Java code I do the following:
>
> String endpoint =
> "http://testserver:8200/KundeKerneInternOutbound/PrivatKundeEventModtage
> rServicePS";
>
> URL wsdl = new URL(endpoint + "?wsdl");
>
> Service service = Service.create(wsdl, new
> QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
> ventModtagerService",
> "PrivatKundeEventModtagerServiceBindingQSService"));
>
> QName portQName = new
> QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
> ventModtagerService", "PrivatKundeEventModtagerServiceBindingQSPort");
>
>
>
> PrivatKundeEventModtagerServicePortType x509Port =
> service.getPort(portQName,
> PrivatKundeEventModtagerServicePortType.class);
>
> return x509Port;
>
>
>
> Thanks in advance
>
>
>
> /Jeppe
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
SV: WS-Policy jaxws-client defined in Spring using createdFromAPI - problem under JBoss 6
Posted by Jeppe Cramon <xj...@dsb.dk>.
Hi
A small update for those who looked at the original mail.
I ended up hacking a solution which is ugly but works.
If others have a better suggestions I'm all ears :)
If it's the "best" solution, then perhaps others in the same situation
can be helped in the future by seeing the hack.
// Point to a WS-Policy less contract
// The reason is that JBossWS-native can't handle parsing the WS-Policy
enabled contract
Service service =
Service.create(this.getClass().getResource("kundekerne/intern/events/udh
entning/PrivatKundeEventUdhentningsService/PrivatKundeEventUdhentningsSe
rvice.wsdl"), new
QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
ventModtagerService", "PrivatKundeEventModtagerService"));
// WSDL endpoint which points to the WS-Policy enabled contract
String endpoint = getEndPointUrl();
URL wsdl = new URL(endpoint + "?wsdl");
QName serviceQName = new
QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
ventModtagerService",
"PrivatKundeEventModtagerServiceBindingQSService");
// Access the Service delegate field and override its value (change from
JBossWS-Native to CXF)
Field delegateField = ReflectUtils.getField(Service.class, "delegate");
ReflectUtils.makeAccessible(delegateField);
// Override the value
ReflectUtils.setFieldValue(delegateField, service, new
ProviderImpl().createServiceDelegate(wsdl, serviceQName,
Service.class));
// Get the port
QName portQName = new
QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
ventModtagerService", "PrivatKundeEventModtagerServiceBindingQSPort");
return service.getPort(portQName,
PrivatKundeEventModtagerServicePortType.class);
/Jeppe
-----Oprindelig meddelelse-----
Fra: Jeppe Cramon [mailto:xjecr@dsb.dk]
Sendt: 19. januar 2012 15:06
Til: users@cxf.apache.org
Emne: WS-Policy jaxws-client defined in Spring using createdFromAPI -
problem under JBoss 6
Hi
Thanks to previous help on this message list we've managed to create a
jax-ws client against an Oracle Service Bus endpoint which uses
WS-Security/WS-Policy
.
The problem is that everything works fine in pure Java (test) and under
Jetty & Tomcat. However for real use I need to deploy it under JBoss 6
AS.
However the CXF version Jboss 6 AS comes with (2.3.1) doesn't work
(fails early with a NPE during policy initialization). So after reading
up on it, I followed the suggested solution which is to install
JBossWS-Native under JBoss 6 and then bundle our own CXF (version 2.5.1)
with the WAR file.
This works nicely for all other service clients, except for the ONLY one
that's done using createdFromAPI=true - the problem occurs because we
need to instantiate it using Service.getPort()(mostly since I don't know
of other ways to create the Jaxws instance from within Spring for this
createdFromAPI case) ...
--->When we do this, JBoss-WS Native then takes over a JAX-WS Provider
and then it wont work :-/
The question is - how do it create my jaxws client so I can call the
secured endpoint (ie. Still use createdFromAPI) and still run the thing
under JBoss 6?
Here's how I've done it so far:
The definition is done in Spring (after an example I found):
<cxf:bus>
<cxf:features>
<p:policies />
<cxf:logging />
</cxf:features>
</cxf:bus>
<jaxws:client
name="{http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
ventModtagerService}PrivatKundeEventModtagerServiceBindingQSPort"
createdFromAPI="true">
<jaxws:properties>
<entry key="ws-security.callback-handler"
value="dk.dsb.ic.kundekerne.security.ClientKeystorePasswordCallback" />
<entry key="ws-security.encryption.properties"
value="security/clientKeystore.properties" />
<entry key="ws-security.encryption.username"
value="osb-public" />
<entry key="ws-security.signature.properties"
value="security/clientKeystore.properties" />
<entry key="ws-security.signature.username"
value="kundekerne" />
</jaxws:properties>
<jaxws:handlers>
<bean
class="dk.dsb.ic.kundekerne.OutgoingIgpClientIgpHeaderHandler"/>
</jaxws:handlers>
</jaxws:client>
And from within the Java code I do the following:
String endpoint =
"http://testserver:8200/KundeKerneInternOutbound/PrivatKundeEventModtage
rServicePS";
URL wsdl = new URL(endpoint + "?wsdl");
Service service = Service.create(wsdl, new
QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
ventModtagerService",
"PrivatKundeEventModtagerServiceBindingQSService"));
QName portQName = new
QName("http://ic.dsb.dk/kundekerne/intern/events/modtagelse/PrivatKundeE
ventModtagerService", "PrivatKundeEventModtagerServiceBindingQSPort");
PrivatKundeEventModtagerServicePortType x509Port =
service.getPort(portQName,
PrivatKundeEventModtagerServicePortType.class);
return x509Port;
Thanks in advance
/Jeppe