You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gerhard Schlager <ma...@gerhard-schlager.at> on 2008/04/16 09:39:00 UTC

CXF, WS-Policy and Spring

Hello!

I'm currently trying to create a web service with CXF that can be used by a
.NET client (WCF).
In the documentation of Sun's Metro I read about WSIT which supports the
interoperability between Java and .NET.

WSIT in NetBeans is automatically adding a few things to the WSDL:

<wsp:Policy wsu:Id="HelloWorld_policy">
  <wsp:ExactlyOne>
    <wsp:All>
      <wsrm:RMAssertion>
        <wsrm:InactivityTimeout Milliseconds="600000"/>
        <wsrm:AcknowledgementInterval Milliseconds="200"/>
      </wsrm:RMAssertion>
      <wsoma:OptimizedMimeSerialization/> 
    </wsp:All>
  </wsp:ExactlyOne>
</wsp:Policy>

Can I do the same thing with CXF? I tried adding the following to the
endpoint's Spring bean:

<bean id="classifierService" class="com.example.HelloWorldImpl">
  <!-- properties -->
</bean>

<jaxws:endpoint id="helloWorldEndpoint"
implementorClass="com.example.HelloWorldImpl" implementor="#helloWorld"
address="/helloWorld">
  <jaxws:properties>
    <entry key="mtom-enabled" value="true" />
  </jaxws:properties>
  <jaxws:features>
    <wsp:Policy>
      <wsrm:RMAssertion>
        <wsrm:InactivityTimeout Milliseconds="600000"/>
        <wsrm:AcknowledgementInterval Milliseconds="200" />
      </wsrm:RMAssertion>
      <wsam:Addressing/>
      <mtom:OptimizedMimeSerialization />
    </wsp:Policy>
  </jaxws:features>
</jaxws:endpoint>

However, that didn't work as expected. Spring throws some type conversion
exceptions when I add the <jaxws:features> to the endpoint's bean. Am I
doing something completely wrong?
I'd be really grateful if somebody could provide a working example that
shows a complete Spring configuration file with namespaces, schemaLocations
and the policy configuration.

Thanks in advance for your help.

Best regards,
Gerhard
-- 
View this message in context: http://www.nabble.com/CXF%2C-WS-Policy-and-Spring-tp16718063p16718063.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF, WS-Policy and Spring

Posted by Glen Mazza <gl...@verizon.net>.
I believe WS-Policy is not yet completely implemented in CXF.  I think
that is targeted for 2.1.

Glen

Am Mittwoch, den 16.04.2008, 00:39 -0700 schrieb Gerhard Schlager:
> Hello!
> 
> I'm currently trying to create a web service with CXF that can be used by a
> .NET client (WCF).
> In the documentation of Sun's Metro I read about WSIT which supports the
> interoperability between Java and .NET.
> 
> WSIT in NetBeans is automatically adding a few things to the WSDL:
> 
> <wsp:Policy wsu:Id="HelloWorld_policy">
>   <wsp:ExactlyOne>
>     <wsp:All>
>       <wsrm:RMAssertion>
>         <wsrm:InactivityTimeout Milliseconds="600000"/>
>         <wsrm:AcknowledgementInterval Milliseconds="200"/>
>       </wsrm:RMAssertion>
>       <wsoma:OptimizedMimeSerialization/> 
>     </wsp:All>
>   </wsp:ExactlyOne>
> </wsp:Policy>
> 
> Can I do the same thing with CXF? I tried adding the following to the
> endpoint's Spring bean:
> 
> <bean id="classifierService" class="com.example.HelloWorldImpl">
>   <!-- properties -->
> </bean>
> 
> <jaxws:endpoint id="helloWorldEndpoint"
> implementorClass="com.example.HelloWorldImpl" implementor="#helloWorld"
> address="/helloWorld">
>   <jaxws:properties>
>     <entry key="mtom-enabled" value="true" />
>   </jaxws:properties>
>   <jaxws:features>
>     <wsp:Policy>
>       <wsrm:RMAssertion>
>         <wsrm:InactivityTimeout Milliseconds="600000"/>
>         <wsrm:AcknowledgementInterval Milliseconds="200" />
>       </wsrm:RMAssertion>
>       <wsam:Addressing/>
>       <mtom:OptimizedMimeSerialization />
>     </wsp:Policy>
>   </jaxws:features>
> </jaxws:endpoint>
> 
> However, that didn't work as expected. Spring throws some type conversion
> exceptions when I add the <jaxws:features> to the endpoint's bean. Am I
> doing something completely wrong?
> I'd be really grateful if somebody could provide a working example that
> shows a complete Spring configuration file with namespaces, schemaLocations
> and the policy configuration.
> 
> Thanks in advance for your help.
> 
> Best regards,
> Gerhard


Re: CXF, WS-Policy and Spring

Posted by Gerhard Schlager <ma...@gerhard-schlager.at>.
Hello Sergey,


Sergey Beryozkin wrote:
> 
> Thanks Freeman. Yes, I need to clarify that it will work indeed this way,
> it's just that the automatic publication of such policy expressions into a
> published WSDL (to be consumed by a NET client in this case) is not
> supported at this stage so that's why I was suggesting to put them into an
> explicit WSDL document and then link to that wsdl document from a
> jaxws:endpoint definition
> 

Please correct me if I'm wrong. Are you saying I can use my existing "Java
first" webservice? All I need to do is add a WSDL document to the endpoint.
That would be great. I'll try this out. Do I still need to add the WS-Policy
to the endpoint via <jaxws:features> so that CXF knows what I want to do or
is it enough when I add the policy to the WSDL file?

Best regards,
Gerhard
-- 
View this message in context: http://www.nabble.com/CXF%2C-WS-Policy-and-Spring-tp16718063p16732983.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF, WS-Policy and Spring

Posted by Freeman Fang <fr...@gmail.com>.
Hi Sergey,

Right,  the wsdl is only contract between cxf server and .net client,  
so if cxf can't publish the policy assertion into wsdl, the .net client 
have no idea about the policy configuration. If client side is also cxf, 
we can use same spring way as server to enable ws-policy for client.
Thanks for clarifying this issue for me, :-)

Freeman

Sergey Beryozkin wrote:
> Thanks Freeman. Yes, I need to clarify that it will work indeed this way, it's just that the automatic publication of such policy expressions into a published WSDL (to be consumed by a NET client in this case) is not supported at this stage so that's why I was suggesting to put them into an explicit WSDL document and then link to that wsdl document from a jaxws:endpoint definition
>
> Cheers, Sergey
>
>
> From: "Freeman Fang" <fr...@gmail.com>
> To: <cx...@incubator.apache.org>
> Sent: Wednesday, April 16, 2008 2:50 PM
> Subject: Re: CXF, WS-Policy and Spring
>
>
>   
>> Hi Gerhard,
>>
>> I'm not expert of ws-policy, but add spring configure to jaxws:endpoint 
>> per as below just works for me
>> <jaxws:features>
>>    <wsp:Policy>
>>      <wsrm:RMAssertion>
>>        <wsrm:InactivityTimeout Milliseconds="600000"/>
>>        <wsrm:AcknowledgementInterval Milliseconds="200" />
>>      </wsrm:RMAssertion>
>>      <wsam:Addressing>
>>         <wsp:Policy/>
>>      </wsam:Addressing>
>>      <mtom:OptimizedMimeSerialization />
>>    </wsp:Policy>
>>  </jaxws:features>
>> Also you need add namespace definition
>>      xmlns:wsp="http://www.w3.org/2006/07/ws-policy"
>>      xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
>>      xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata"
>>      
>> xmlns:mtom="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"
>>
>> Regards
>>
>> Freeman
>>
>> Gerhard Schlager wrote:
>>     
>>> Hello Sergey,
>>>
>>>
>>> Sergey Beryozkin wrote:
>>>   
>>>       
>>>> I'm sorry to say it but I've never got to ensuring that for java-first
>>>> services WS-Policy expressions get automatically added to a (generated)
>>>> WSDL. I can't commit myself to fixing this issue at this stage, but
>>>> whenever I get a chance to look at a WS-Policy stuff, I'll get it fixed
>>>> first as it's obvious it's a major blocket to utilizing the CXF WS-Policy
>>>> framework at a wider scale.
>>>>
>>>> Current WS-Policy implementation is a bit complicated, but the fix for
>>>> this issue should be reasonably simple, it would probably require an
>>>> update to a WS-PolicyFeature implementation which should register the
>>>> policy extensors it discovers from a spring configuration with either the
>>>> Endpoint or WSDLManager...
>>>>
>>>>     
>>>>         
>>> Now I'm a little bit confused. After reading [1] I thought it would be
>>> possible to configure the WS-Policy with Spring. I just couldn't get it
>>> working because of some exceptions (I can post them in a few hours if you
>>> need them) that Spring was throwing at me. ;-)
>>> So, are you saying it currently can't be done at all? That would be too bad.
>>> I had some problems with Sun's Metro in conjunction with Spring and
>>> Hibernate so I switched back to CXF. It looks like I can't use both of them.
>>> Writing my own patch is not possible since I need a solution within the next
>>> few days.
>>>
>>> Would it work if I used WSDL first? However, I guess I won't be able to use
>>> Spring's dependency injection then, will I? :-(
>>>
>>> [1] http://netzooid.com/blog/2007/04/23/cxf-spring-and-ws-policy-internals/
>>>
>>>       
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>
>   


Re: CXF, WS-Policy and Spring

Posted by Sergey Beryozkin <se...@iona.com>.
Thanks Freeman. Yes, I need to clarify that it will work indeed this way, it's just that the automatic publication of such policy expressions into a published WSDL (to be consumed by a NET client in this case) is not supported at this stage so that's why I was suggesting to put them into an explicit WSDL document and then link to that wsdl document from a jaxws:endpoint definition

Cheers, Sergey


From: "Freeman Fang" <fr...@gmail.com>
To: <cx...@incubator.apache.org>
Sent: Wednesday, April 16, 2008 2:50 PM
Subject: Re: CXF, WS-Policy and Spring


> Hi Gerhard,
> 
> I'm not expert of ws-policy, but add spring configure to jaxws:endpoint 
> per as below just works for me
> <jaxws:features>
>    <wsp:Policy>
>      <wsrm:RMAssertion>
>        <wsrm:InactivityTimeout Milliseconds="600000"/>
>        <wsrm:AcknowledgementInterval Milliseconds="200" />
>      </wsrm:RMAssertion>
>      <wsam:Addressing>
>         <wsp:Policy/>
>      </wsam:Addressing>
>      <mtom:OptimizedMimeSerialization />
>    </wsp:Policy>
>  </jaxws:features>
> Also you need add namespace definition
>      xmlns:wsp="http://www.w3.org/2006/07/ws-policy"
>      xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
>      xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata"
>      
> xmlns:mtom="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"
> 
> Regards
> 
> Freeman
> 
> Gerhard Schlager wrote:
>> Hello Sergey,
>>
>>
>> Sergey Beryozkin wrote:
>>   
>>> I'm sorry to say it but I've never got to ensuring that for java-first
>>> services WS-Policy expressions get automatically added to a (generated)
>>> WSDL. I can't commit myself to fixing this issue at this stage, but
>>> whenever I get a chance to look at a WS-Policy stuff, I'll get it fixed
>>> first as it's obvious it's a major blocket to utilizing the CXF WS-Policy
>>> framework at a wider scale.
>>>
>>> Current WS-Policy implementation is a bit complicated, but the fix for
>>> this issue should be reasonably simple, it would probably require an
>>> update to a WS-PolicyFeature implementation which should register the
>>> policy extensors it discovers from a spring configuration with either the
>>> Endpoint or WSDLManager...
>>>
>>>     
>>
>> Now I'm a little bit confused. After reading [1] I thought it would be
>> possible to configure the WS-Policy with Spring. I just couldn't get it
>> working because of some exceptions (I can post them in a few hours if you
>> need them) that Spring was throwing at me. ;-)
>> So, are you saying it currently can't be done at all? That would be too bad.
>> I had some problems with Sun's Metro in conjunction with Spring and
>> Hibernate so I switched back to CXF. It looks like I can't use both of them.
>> Writing my own patch is not possible since I need a solution within the next
>> few days.
>>
>> Would it work if I used WSDL first? However, I guess I won't be able to use
>> Spring's dependency injection then, will I? :-(
>>
>> [1] http://netzooid.com/blog/2007/04/23/cxf-spring-and-ws-policy-internals/
>>

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: CXF, WS-Policy and Spring

Posted by Sergey Beryozkin <se...@iona.com>.
I think you should inline policy expressions like this, have a look please at ws-policy system tests :

<beans xmlns:p="http://cxf.apache.org/policy"
xsi:schemaLocation="...http://cxf.apache.org/policy http://cxf.apache.org/schemas/policy.xsd...">
> <jaxws:endpoint id="echoService"
> implementor="com.example.EchoService" address="/echo">
> <jaxws:features>
<p:policies>
<wsp:PolicyReference URI="#PolicyId"/>
</p:policies>

> </jaxws:features>
> </jaxws:endpoint>

<wsp:Policy wsu:Id="PolicyId">
<!-- ... -->
 </wsp:Policy>
</beans>

But, as I said earlier, CXF is not capable yet of automatically propagating such policy expressions into a generated wsdl, hence, at 
the moment, you need to do something like this :

<jaxws:endpoint id="echoService"
 wsdlLocation="META-INF/wsdl/hello.wsdl"/>

With no policy expressions in the spring config but only in the explicitly created wsdl, this is only needed if the task is to have 
a non-CXF policy aware client like a NET client be capable of consuming the endpoint as expected :

<wsdl:definitions>
<wsdl:service>
<wsdl:port>
<!-- your policy expression goes here -->
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Hope this helps
Sergey


----- Original Message ----- 
From: "Gerhard Schlager" <ma...@gerhard-schlager.at>
To: <cx...@incubator.apache.org>
Sent: Wednesday, April 16, 2008 10:04 PM
Subject: Re: CXF, WS-Policy and Spring


>
> BTW, this is the content of my Spring config file which leads to the
> exception.
>
> <?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"
> xmlns:wsp="http://www.w3.org/2006/07/ws-policy"
> xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
> xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata"
>
> xmlns:mtom="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"
> 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">
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
> <jaxws:endpoint id="echoService"
> implementor="com.example.EchoService" address="/echo">
> <jaxws:features>
> <wsp:Policy>
> <wsrm:RMAssertion>
> <wsrm:InactivityTimeout Milliseconds="600000" />
> <wsrm:AcknowledgementInterval Milliseconds="200" />
> </wsrm:RMAssertion>
> <wsam:Addressing>
> <wsp:Policy />
> </wsam:Addressing>
> <mtom:OptimizedMimeSerialization />
> </wsp:Policy>
> </jaxws:features>
> </jaxws:endpoint>
> </beans>
>
> I have the following JARs in my build path:
> asm-2.2.3.jar
> commons-logging-1.1.jar
> cxf-2.0.5-incubator.jar
> geronimo-activation_1.1_spec-1.0.2.jar
> geronimo-annotation_1.0_spec-1.1.1.jar
> geronimo-javamail_1.4_spec-1.2.jar
> geronimo-servlet_2.5_spec-1.1.2.jar
> geronimo-stax-api_1.0_spec-1.0.1.jar
> geronimo-ws-metadata_2.0_spec-1.1.2.jar
> jaxb-api-2.0.jar
> jaxb-impl-2.0.5.jar
> jaxws-api-2.0.jar
> jetty-6.1.8.jar
> jetty-util-6.1.8.jar
> neethi-2.0.2.jar
> saaj-api-1.3.jar
> saaj-impl-1.3.jar
> slf4j-api-1.3.1.jar
> slf4j-jdk14-1.3.1.jar
> wsdl4j-1.6.1.jar
> wstx-asl-3.2.4.jar
> xml-resolver-1.2.jar
> XmlSchema-1.3.2.jar
> spring.jar
>
> Maybe those details help finding the cause of the exception.
> -- 
> View this message in context: http://www.nabble.com/CXF%2C-WS-Policy-and-Spring-tp16718063p16733491.html
> Sent from the cxf-user mailing list archive at Nabble.com. 

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: CXF, WS-Policy and Spring

Posted by Gerhard Schlager <ma...@gerhard-schlager.at>.
BTW, this is the content of my Spring config file which leads to the
exception.

<?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"
	xmlns:wsp="http://www.w3.org/2006/07/ws-policy"
	xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
	xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata"

xmlns:mtom="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"
	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">

	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

	<jaxws:endpoint id="echoService"
		implementor="com.example.EchoService" address="/echo">
		<jaxws:features>
			<wsp:Policy>
				<wsrm:RMAssertion>
					<wsrm:InactivityTimeout Milliseconds="600000" />
					<wsrm:AcknowledgementInterval Milliseconds="200" />
				</wsrm:RMAssertion>
				<wsam:Addressing>
					<wsp:Policy />
				</wsam:Addressing>
				<mtom:OptimizedMimeSerialization />
			</wsp:Policy>
		</jaxws:features>
	</jaxws:endpoint>
</beans>

I have the following JARs in my build path:
asm-2.2.3.jar
commons-logging-1.1.jar
cxf-2.0.5-incubator.jar
geronimo-activation_1.1_spec-1.0.2.jar
geronimo-annotation_1.0_spec-1.1.1.jar
geronimo-javamail_1.4_spec-1.2.jar
geronimo-servlet_2.5_spec-1.1.2.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
geronimo-ws-metadata_2.0_spec-1.1.2.jar
jaxb-api-2.0.jar
jaxb-impl-2.0.5.jar
jaxws-api-2.0.jar
jetty-6.1.8.jar
jetty-util-6.1.8.jar
neethi-2.0.2.jar
saaj-api-1.3.jar
saaj-impl-1.3.jar
slf4j-api-1.3.1.jar
slf4j-jdk14-1.3.1.jar
wsdl4j-1.6.1.jar
wstx-asl-3.2.4.jar
xml-resolver-1.2.jar
XmlSchema-1.3.2.jar
spring.jar

Maybe those details help finding the cause of the exception.
-- 
View this message in context: http://www.nabble.com/CXF%2C-WS-Policy-and-Spring-tp16718063p16733491.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF, WS-Policy and Spring

Posted by Gerhard Schlager <ma...@gerhard-schlager.at>.
Hi Freeman,

I tried that. However, I get the following exception. Do you have any idea
what the cause could be?

16.04.2008 22:25:16 sun.reflect.NativeMethodAccessorImpl invoke0
SCHWERWIEGEND: Nested in
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'echoService': Initialization of bean failed; nested exception is
org.springframework.beans.TypeMismatchException: Failed to convert property
value of type [java.util.ArrayList] to required type [java.util.List] for
property 'features'; nested exception is java.lang.IllegalArgumentException:
Cannot convert value of type [org.apache.cxf.ws.policy.PolicyBean] to
required type [org.apache.cxf.feature.AbstractFeature] for property
'features[0]': no matching editors or conversion strategy found
Related cause:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'echoService': Unsatisfied dependency expressed
through constructor argument with index 2 of type [java.lang.String]:
Ambiguous constructor argument types - did you specify the correct bean
references as constructor arguments?
Related cause:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'echoService': Unsatisfied dependency expressed
through constructor argument with index 2 of type [java.lang.String]:
Ambiguous constructor argument types - did you specify the correct bean
references as constructor arguments?
Related cause:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'echoService': Unsatisfied dependency expressed
through constructor argument with index 2 of type
[org.apache.cxf.jaxws.JaxWsServerFactoryBean]: Ambiguous constructor
argument types - did you specify the correct bean references as constructor
arguments?:
java.lang.IllegalArgumentException: Cannot convert value of type
[org.apache.cxf.ws.policy.PolicyBean] to required type
[org.apache.cxf.feature.AbstractFeature] for property 'features[0]': no
matching editors or conversion strategy found
	at
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:238)
	at
org.springframework.beans.TypeConverterDelegate.convertToTypedCollection(TypeConverterDelegate.java:432)
	at
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:209)
	at
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
	at
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1287)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1248)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
	at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
	at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
	at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
	at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
	at
org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:540)
	at org.mortbay.jetty.servlet.Context.startContext(Context.java:135)
	at
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
	at
org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:510)
	at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at
org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
	at org.mortbay.jetty.Server.doStart(Server.java:222)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at com.example.Server.<init>(Server.java:40)
	at com.example.Server.main(Server.java:47)


Freeman Fang wrote:
> 
> Hi Gerhard,
> 
> I'm not expert of ws-policy, but add spring configure to jaxws:endpoint 
> per as below just works for me
> <jaxws:features>
>     <wsp:Policy>
>       <wsrm:RMAssertion>
>         <wsrm:InactivityTimeout Milliseconds="600000"/>
>         <wsrm:AcknowledgementInterval Milliseconds="200" />
>       </wsrm:RMAssertion>
>       <wsam:Addressing>
>          <wsp:Policy/>
>       </wsam:Addressing>
>       <mtom:OptimizedMimeSerialization />
>     </wsp:Policy>
>   </jaxws:features>
> Also you need add namespace definition
>       xmlns:wsp="http://www.w3.org/2006/07/ws-policy"
>       xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
>       xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata"
>       
> xmlns:mtom="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"
> 
-- 
View this message in context: http://www.nabble.com/CXF%2C-WS-Policy-and-Spring-tp16718063p16732889.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF, WS-Policy and Spring

Posted by Freeman Fang <fr...@gmail.com>.
Hi Gerhard,

I'm not expert of ws-policy, but add spring configure to jaxws:endpoint 
per as below just works for me
<jaxws:features>
    <wsp:Policy>
      <wsrm:RMAssertion>
        <wsrm:InactivityTimeout Milliseconds="600000"/>
        <wsrm:AcknowledgementInterval Milliseconds="200" />
      </wsrm:RMAssertion>
      <wsam:Addressing>
         <wsp:Policy/>
      </wsam:Addressing>
      <mtom:OptimizedMimeSerialization />
    </wsp:Policy>
  </jaxws:features>
Also you need add namespace definition
      xmlns:wsp="http://www.w3.org/2006/07/ws-policy"
      xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
      xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata"
      
xmlns:mtom="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"

Regards

Freeman

Gerhard Schlager wrote:
> Hello Sergey,
>
>
> Sergey Beryozkin wrote:
>   
>> I'm sorry to say it but I've never got to ensuring that for java-first
>> services WS-Policy expressions get automatically added to a (generated)
>> WSDL. I can't commit myself to fixing this issue at this stage, but
>> whenever I get a chance to look at a WS-Policy stuff, I'll get it fixed
>> first as it's obvious it's a major blocket to utilizing the CXF WS-Policy
>> framework at a wider scale.
>>
>> Current WS-Policy implementation is a bit complicated, but the fix for
>> this issue should be reasonably simple, it would probably require an
>> update to a WS-PolicyFeature implementation which should register the
>> policy extensors it discovers from a spring configuration with either the
>> Endpoint or WSDLManager...
>>
>>     
>
> Now I'm a little bit confused. After reading [1] I thought it would be
> possible to configure the WS-Policy with Spring. I just couldn't get it
> working because of some exceptions (I can post them in a few hours if you
> need them) that Spring was throwing at me. ;-)
> So, are you saying it currently can't be done at all? That would be too bad.
> I had some problems with Sun's Metro in conjunction with Spring and
> Hibernate so I switched back to CXF. It looks like I can't use both of them.
> Writing my own patch is not possible since I need a solution within the next
> few days.
>
> Would it work if I used WSDL first? However, I guess I won't be able to use
> Spring's dependency injection then, will I? :-(
>
> [1] http://netzooid.com/blog/2007/04/23/cxf-spring-and-ws-policy-internals/
>   


Re: CXF, WS-Policy and Spring

Posted by Daniel Kulp <dk...@apache.org>.
> Would it work if I used WSDL first? However, I guess I won't be able
> to use Spring's dependency injection then, will I? :-(

Yes you can.  The wsdl first stuff doesn't change the spring injection 
stuff at all.   All it really does is tell the runtime to publish that 
specific wsdl instead of generating one dynamically at runtime.  

Dan



On Wednesday 16 April 2008, Gerhard Schlager wrote:
> Hello Sergey,
>
> Sergey Beryozkin wrote:
> > I'm sorry to say it but I've never got to ensuring that for
> > java-first services WS-Policy expressions get automatically added to
> > a (generated) WSDL. I can't commit myself to fixing this issue at
> > this stage, but whenever I get a chance to look at a WS-Policy
> > stuff, I'll get it fixed first as it's obvious it's a major blocket
> > to utilizing the CXF WS-Policy framework at a wider scale.
> >
> > Current WS-Policy implementation is a bit complicated, but the fix
> > for this issue should be reasonably simple, it would probably
> > require an update to a WS-PolicyFeature implementation which should
> > register the policy extensors it discovers from a spring
> > configuration with either the Endpoint or WSDLManager...
>
> Now I'm a little bit confused. After reading [1] I thought it would be
> possible to configure the WS-Policy with Spring. I just couldn't get
> it working because of some exceptions (I can post them in a few hours
> if you need them) that Spring was throwing at me. ;-)
> So, are you saying it currently can't be done at all? That would be
> too bad. I had some problems with Sun's Metro in conjunction with
> Spring and Hibernate so I switched back to CXF. It looks like I can't
> use both of them. Writing my own patch is not possible since I need a
> solution within the next few days.
>
> Would it work if I used WSDL first? However, I guess I won't be able
> to use Spring's dependency injection then, will I? :-(
>
> [1]
> http://netzooid.com/blog/2007/04/23/cxf-spring-and-ws-policy-internals
>/



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: CXF, WS-Policy and Spring

Posted by Gerhard Schlager <ma...@gerhard-schlager.at>.

Sergey Beryozkin wrote:
> 
> 
>> I had some problems with Sun's Metro in conjunction with Spring and
>> Hibernate so I switched back to CXF.
> 
> Interesting :-). I think you can definitely use Spring and Hibernate in
> CXF.
> 

I already have a working webservice which I created with CXF. However, I had
a few problems when I tried to use it from my .NET client. Then I read about
Metro and WSIT which is heavily tested with Microsoft's WCF. I hoped I could
get rid of my problems (*) by switching to Metro. Well, that didn't work as
well as I hoped it would. At first I couldn't inject my Spring beans into
the endpoint until I figured out that NetBeans is deploying the same
webservice two times. The Spring support works only in one of them. :-/
After that I started porting all of my code which includes some Hibernate
DAOs. Well, I just couldn't find a way to deploy my webservice when I used
Spring and Hibernate. It looks like there were some problems with the JARs.
Of course, the same JARs plus the ones from CXF work without a problem when
I deploy them to my Jetty server ...

To make a long story short, those are the reasons why I switched back to
CXF. So I just hope that I can get this to work as soon as possible since I
have to show this to the tutor of my bachelor thesis at the end of next
week.

(*) Those problems existed in Metro as well, so I guess I'll have to ask
here some more questions about interoperability problems during the next few
days. ;-)
-- 
View this message in context: http://www.nabble.com/CXF%2C-WS-Policy-and-Spring-tp16718063p16733412.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF, WS-Policy and Spring

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

> I had some problems with Sun's Metro in conjunction with Spring and
> Hibernate so I switched back to CXF.

Interesting :-). I think you can definitely use Spring and Hibernate in CXF.
But as far as WS-Policy is concerned, in CXF you just need to put policy expressions, those starting with
wsp:Policy explicitly in WSDL, say, as children of wsdl:service/wsdl:port. So you can use your Spring injection, but the only limitation is that the policy expressions need to reside in a given WSDL document.

It should work just fine...Now, Metro has a better domain-specific WS-Policy support (specifically WS-SecurityPolicy), but the policy expressions which you listed will work in CXF AFAIK... 

Cheers, Sergey


> 
> Hello Sergey,
> 
> 
> Sergey Beryozkin wrote:
>> 
>> I'm sorry to say it but I've never got to ensuring that for java-first
>> services WS-Policy expressions get automatically added to a (generated)
>> WSDL. I can't commit myself to fixing this issue at this stage, but
>> whenever I get a chance to look at a WS-Policy stuff, I'll get it fixed
>> first as it's obvious it's a major blocket to utilizing the CXF WS-Policy
>> framework at a wider scale.
>> 
>> Current WS-Policy implementation is a bit complicated, but the fix for
>> this issue should be reasonably simple, it would probably require an
>> update to a WS-PolicyFeature implementation which should register the
>> policy extensors it discovers from a spring configuration with either the
>> Endpoint or WSDLManager...
>> 
> 
> Now I'm a little bit confused. After reading [1] I thought it would be
> possible to configure the WS-Policy with Spring. I just couldn't get it
> working because of some exceptions (I can post them in a few hours if you
> need them) that Spring was throwing at me. ;-)
> So, are you saying it currently can't be done at all? That would be too bad.
> I had some problems with Sun's Metro in conjunction with Spring and
> Hibernate so I switched back to CXF. It looks like I can't use both of them.
> Writing my own patch is not possible since I need a solution within the next
> few days.
> 
> Would it work if I used WSDL first? However, I guess I won't be able to use
> Spring's dependency injection then, will I? :-(
> 
> [1] http://netzooid.com/blog/2007/04/23/cxf-spring-and-ws-policy-internals/
> -- 
> View this message in context: http://www.nabble.com/CXF%2C-WS-Policy-and-Spring-tp16718063p16721675.html
> Sent from the cxf-user mailing list archive at Nabble.com.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: CXF, WS-Policy and Spring

Posted by Gerhard Schlager <ma...@gerhard-schlager.at>.
Hello Sergey,


Sergey Beryozkin wrote:
> 
> I'm sorry to say it but I've never got to ensuring that for java-first
> services WS-Policy expressions get automatically added to a (generated)
> WSDL. I can't commit myself to fixing this issue at this stage, but
> whenever I get a chance to look at a WS-Policy stuff, I'll get it fixed
> first as it's obvious it's a major blocket to utilizing the CXF WS-Policy
> framework at a wider scale.
> 
> Current WS-Policy implementation is a bit complicated, but the fix for
> this issue should be reasonably simple, it would probably require an
> update to a WS-PolicyFeature implementation which should register the
> policy extensors it discovers from a spring configuration with either the
> Endpoint or WSDLManager...
> 

Now I'm a little bit confused. After reading [1] I thought it would be
possible to configure the WS-Policy with Spring. I just couldn't get it
working because of some exceptions (I can post them in a few hours if you
need them) that Spring was throwing at me. ;-)
So, are you saying it currently can't be done at all? That would be too bad.
I had some problems with Sun's Metro in conjunction with Spring and
Hibernate so I switched back to CXF. It looks like I can't use both of them.
Writing my own patch is not possible since I need a solution within the next
few days.

Would it work if I used WSDL first? However, I guess I won't be able to use
Spring's dependency injection then, will I? :-(

[1] http://netzooid.com/blog/2007/04/23/cxf-spring-and-ws-policy-internals/
-- 
View this message in context: http://www.nabble.com/CXF%2C-WS-Policy-and-Spring-tp16718063p16721675.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF, WS-Policy and Spring

Posted by Sergey Beryozkin <se...@iona.com>.
Hi,
I'm sorry to say it but I've never got to ensuring that for java-first services WS-Policy expressions get automatically added to a (generated) WSDL. I can't commit myself to fixing this issue at this stage, but whenever I get a chance to look at a WS-Policy stuff, I'll get it fixed first as it's obvious it's a major blocket to utilizing the CXF WS-Policy framework at a wider scale.

Current WS-Policy implementation is a bit complicated, but the fix for this issue should be reasonably simple, it would probably require an update to a WS-PolicyFeature implementation which should register the policy extensors it discovers from a spring configuration with either the Endpoint or WSDLManager...

The only workaround at this stage is to explictly create a WSDL and have those expressions bound to the right extension points. The other possibility is to consider creating a patch if it's a real blocker...

Cheers, Sergey

----- Original Message ----- 
From: "Gerhard Schlager" <ma...@gerhard-schlager.at>
To: <cx...@incubator.apache.org>
Sent: Wednesday, April 16, 2008 8:39 AM
Subject: CXF, WS-Policy and Spring


> 
> Hello!
> 
> I'm currently trying to create a web service with CXF that can be used by a
> .NET client (WCF).
> In the documentation of Sun's Metro I read about WSIT which supports the
> interoperability between Java and .NET.
> 
> WSIT in NetBeans is automatically adding a few things to the WSDL:
> 
> <wsp:Policy wsu:Id="HelloWorld_policy">
>  <wsp:ExactlyOne>
>    <wsp:All>
>      <wsrm:RMAssertion>
>        <wsrm:InactivityTimeout Milliseconds="600000"/>
>        <wsrm:AcknowledgementInterval Milliseconds="200"/>
>      </wsrm:RMAssertion>
>      <wsoma:OptimizedMimeSerialization/> 
>    </wsp:All>
>  </wsp:ExactlyOne>
> </wsp:Policy>
> 
> Can I do the same thing with CXF? I tried adding the following to the
> endpoint's Spring bean:
> 
> <bean id="classifierService" class="com.example.HelloWorldImpl">
>  <!-- properties -->
> </bean>
> 
> <jaxws:endpoint id="helloWorldEndpoint"
> implementorClass="com.example.HelloWorldImpl" implementor="#helloWorld"
> address="/helloWorld">
>  <jaxws:properties>
>    <entry key="mtom-enabled" value="true" />
>  </jaxws:properties>
>  <jaxws:features>
>    <wsp:Policy>
>      <wsrm:RMAssertion>
>        <wsrm:InactivityTimeout Milliseconds="600000"/>
>        <wsrm:AcknowledgementInterval Milliseconds="200" />
>      </wsrm:RMAssertion>
>      <wsam:Addressing/>
>      <mtom:OptimizedMimeSerialization />
>    </wsp:Policy>
>  </jaxws:features>
> </jaxws:endpoint>
> 
> However, that didn't work as expected. Spring throws some type conversion
> exceptions when I add the <jaxws:features> to the endpoint's bean. Am I
> doing something completely wrong?
> I'd be really grateful if somebody could provide a working example that
> shows a complete Spring configuration file with namespaces, schemaLocations
> and the policy configuration.
> 
> Thanks in advance for your help.
> 
> Best regards,
> Gerhard
> -- 
> View this message in context: http://www.nabble.com/CXF%2C-WS-Policy-and-Spring-tp16718063p16718063.html
> Sent from the cxf-user mailing list archive at Nabble.com.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland