You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Haselmann, Till" <Ti...@viadee.de> on 2007/10/29 14:56:19 UTC

Using WS-Policy with CXF

Dear NG,

I would like to use WS-Policy with CXF.  For that, I prepared a WSDL-file that contains a policy plus a policy reference (working well with Sun's Metro).  I followed the scarce info from the user guide to activate the policy engine and tried the following config:

<?xml version="1.0" encoding="UTF-8"?>
<!-- CXF configuration file -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:http="http://cxf.apache.org/transports/http/configuration"
	xmlns:p="http://cxf.apache.org/policy-config"
	xsi:schemaLocation="http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
	       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

	<bean id="org.apache.cxf.ws.policy.PolicyEngine" class="org.apache.cxf.ws.policy.spring.InitializingPolicyEngine">
		<property name="bus" ref="cxf" />
		<property name="enabled" value="true" />
	</bean>

	<p:engine enabled="true" ignoreUnknownAssertions="false" />

</beans>

but then I get an error because the assertion to enable the policy engine is not recognized by the parser:

    [java] Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'p:engine'.
     [java] 	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
     [java] 	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
     [java] 	at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
     [java] 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:351)

What's the problem here?  How do I enable CXF to load the policy and conform to the security assertions within?  I'm using CXF 2.0.2.

Regards,
   Till.

---------------------------------------------------------------------
Till Haselmann
Diplomand
viadee Unternehmensberatung GmbH
till.haselmann@viadee.de
www.viadee.de


Re: Using WS-Policy with CXF

Posted by Daniel Kulp <dk...@apache.org>.
On Monday 08 November 2010 6:55:08 am almo wrote:
> IU have the same problem, did you find how to solve it??


If using a custom spring context instead of a default Bus, you likely need to 
import:

META-INF/cxf/cxf-extension-policy.xml
META-INF/cxf/cxf-extension-ws-security.xml
META-INF/cxf/cxf-extension-addr.xml

to get all the addressing and policy related things.  Not 100% sure though.  A 
sample app would be nice.


-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

RE: Using WS-Policy with CXF

Posted by almo <po...@al-moayed.com>.
IU have the same problem, did you find how to solve it??
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Using-WS-Policy-with-CXF-tp552435p3254943.html
Sent from the cxf-user mailing list archive at Nabble.com.

RE: Using WS-Policy with CXF

Posted by "Haselmann, Till" <Ti...@viadee.de>.
If I try the alternative approach from the userguide:

<?xml version="1.0" encoding="UTF-8"?>
<!-- CXF configuration file -->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:http="http://cxf.apache.org/transports/http/configuration" xmlns:cxf="http://cxf.apache.org/core" xmlns:p="http://cxf.apache.org/policy-config"
	xsi:schemaLocation="http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org/policy-config http://cxf.apache.org/policy-config.xsd">

	<cxf:bus>
		<cxf:features>
			<p:policies ignoreUnknownAssertions="true" />
		</cxf:features>
	</cxf:bus>
</beans>

I get the following exception about an unknown namespace handler:

     [java] Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate NamespaceHandler for namespace [http://cxf.apache.org/policy-config]
     [java] Offending resource: class path resource [cxf.xml]
     [java] 	at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
     [java] 	at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
     [java] 	at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
     [java] 	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:261)
     [java] 	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1111)
     [java] 	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseNestedCustomElement(BeanDefinitionParserDelegate.java:1152)
     [java] 	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parsePropertySubElement(BeanDefinitionParserDelegate.java:781)
     [java] 	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseListElement(BeanDefinitionParserDelegate.java:903)
     [java] 	at org.apache.cxf.bus.spring.BusDefinitionParser.mapElement(BusDefinitionParser.java:48)
     [java] 	at org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.parseChildElements(AbstractBeanDefinitionParser.java:106)
     [java] 	at org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.doParse(AbstractBeanDefinitionParser.java:56)
     [java] 	at org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:70)
     [java] 	at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:56)
     [java] 	at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
     [java] 	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1114)
     [java] 	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1104)
     [java] 	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
     [java] 	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90)
     [java] 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:458)
     [java] 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:353)
     [java] 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
     [java] 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
     [java] 	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
     [java] 	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:108)
     [java] 	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
     [java] 	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:100)
     [java] 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
     [java] 	at org.apache.cxf.bus.spring.BusApplicationContext.<init>(BusApplicationContext.java:71)
     [java] 	at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:84)

> -----Original Message-----
> From: Haselmann, Till
> Sent: Monday, October 29, 2007 2:56 PM
> To: cxf-user@incubator.apache.org
> Subject: Using WS-Policy with CXF
> 
> Dear NG,
> 
> I would like to use WS-Policy with CXF.  For that, I prepared a WSDL-file
> that contains a policy plus a policy reference (working well with Sun's
> Metro).  I followed the scarce info from the user guide to activate the
> policy engine and tried the following config:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- CXF configuration file -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xmlns:http="http://cxf.apache.org/transports/http/configuration"
> 	xmlns:p="http://cxf.apache.org/policy-config"
> 	xsi:schemaLocation="http://cxf.apache.org/transports/http/configurati
> on http://cxf.apache.org/schemas/configuration/http-conf.xsd
> 	       http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd">
> 
> 	<bean id="org.apache.cxf.ws.policy.PolicyEngine"
> class="org.apache.cxf.ws.policy.spring.InitializingPolicyEngine">
> 		<property name="bus" ref="cxf" />
> 		<property name="enabled" value="true" />
> 	</bean>
> 
> 	<p:engine enabled="true" ignoreUnknownAssertions="false" />
> 
> </beans>
> 
> but then I get an error because the assertion to enable the policy engine is
> not recognized by the parser:
> 
>     [java] Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c:
> The matching wildcard is strict, but no declaration can be found for element
> 'p:engine'.
>      [java] 	at
> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseExc
> eption(Unknown Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown
> Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
> Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
> Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporte
> r.reportError(Unknown Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaErr
> or(Unknown Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElem
> ent(Unknown Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(Un
> known Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartEle
> ment(Unknown Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Fragme
> ntContentDriver.next(Unknown Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown
> Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown
> Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDo
> cument(Unknown Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
> Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
> Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
>      [java] 	at
> com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
> Source)
>      [java] 	at
> org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(Defa
> ultDocumentLoader.java:76)
>      [java] 	at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefin
> itions(XmlBeanDefinitionReader.java:351)
> 
> What's the problem here?  How do I enable CXF to load the policy and conform
> to the security assertions within?  I'm using CXF 2.0.2.
> 
> Regards,
>    Till.
> 
> ---------------------------------------------------------------------
> Till Haselmann
> Diplomand
> viadee Unternehmensberatung GmbH
> till.haselmann@viadee.de
> www.viadee.de