Author: bmaxwell
Date: 2011-05-24 17:08:25 -0400 (Tue, 24 May 2011)
New Revision: 14425
Added:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http-addr-server.xml
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter_addr.wsdl
Modified:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
Log:
[JBPAPP-6440] backport CXF-3544 - The nested policy reference can not be resolved
Modified:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java 2011-05-24
20:41:07 UTC (rev 14424)
+++
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java 2011-05-24
21:08:25 UTC (rev 14425)
@@ -30,6 +30,7 @@
import javax.xml.namespace.QName;
import org.apache.cxf.Bus;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.service.model.AbstractDescriptionElement;
import org.apache.cxf.service.model.BindingFaultInfo;
@@ -167,9 +168,31 @@
if (null == ex || null == di) {
return null;
}
+
+ if (di.getProperty("registeredPolicy") == null) {
+ List<UnknownExtensibilityElement> diext =
+ di.getExtensors(UnknownExtensibilityElement.class);
+ if (diext != null) {
+ for (UnknownExtensibilityElement e : diext) {
+ String uri =
e.getElement().getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
+ PolicyConstants.WSU_ID_ATTR_NAME);
+
+ if (PolicyConstants.isPolicyElem(e.getElementType())
+ && !StringUtils.isEmpty(uri)) {
+ Policy policy = builder.getPolicy(e.getElement());
+ String fragement = "#" + uri;
+ registry.register(fragement, policy);
+ registry.register(di.getBaseURI() + fragement, policy);
+ }
+ }
+ }
+ di.setProperty("registeredPolicy", true);
+ }
+
Policy elementPolicy = null;
List<UnknownExtensibilityElement> extensions =
ex.getExtensors(UnknownExtensibilityElement.class);
+
if (null != extensions) {
for (UnknownExtensibilityElement e : extensions) {
Policy p = null;
@@ -240,6 +263,7 @@
if (null != resolved) {
return resolved;
}
+
ReferenceResolver resolver = new LocalServiceModelReferenceResolver(di,
builder);
resolved = resolver.resolveReference(uri);
if (null != resolved) {
Added:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java 2011-05-24
21:08:25 UTC (rev 14425)
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.ws.policy;
+
+import java.util.logging.Logger;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.greeter_control.BasicGreeterService;
+import org.apache.cxf.greeter_control.Greeter;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class NestedAddressingPolicyTest extends AbstractBusClientServerTestBase {
+ public static final String PORT = allocatePort(Server.class);
+
+ private static final Logger LOG = LogUtils.getLogger(HTTPServerPolicyTest.class);
+
+ public static class Server extends AbstractBusTestServerBase {
+
+ protected void run() {
+ SpringBusFactory bf = new SpringBusFactory();
+ Bus bus =
bf.createBus("org/apache/cxf/systest/ws/policy/http-addr-server.xml");
+
+ GreeterImpl implementor = new GreeterImpl();
+ implementor.setThrowAlways(true);
+ Endpoint.publish("http://localhost:" + PORT +
"/SoapContext/GreeterPort", implementor);
+
+ LOG.info("Published greeter endpoint.");
+
+ LoggingInInterceptor in = new LoggingInInterceptor();
+ LoggingOutInterceptor out = new LoggingOutInterceptor();
+
+ bus.getInInterceptors().add(in);
+ bus.getOutInterceptors().add(out);
+ bus.getOutFaultInterceptors().add(out);
+ }
+
+
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+ }
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly",
launchServer(Server.class));
+ }
+
+ @Test
+ public void greetMe() throws Exception {
+
+ // use a plain client
+
+ SpringBusFactory bf = new SpringBusFactory();
+ Bus bus = bf.createBus();
+
+ BasicGreeterService gs = new BasicGreeterService();
+ final Greeter greeter = gs.getGreeterPort();
+
+ updateAddressPort(greeter, PORT);
+ LoggingInInterceptor in = new LoggingInInterceptor();
+ LoggingOutInterceptor out = new LoggingOutInterceptor();
+
+ bus.getInInterceptors().add(in);
+ bus.getOutInterceptors().add(out);
+
+
+ try {
+ greeter.greetMe("mytest");
+ fail("SoapFault expected");
+ } catch (Exception e) {
+ assertTrue("Addressing Header Required message is expected",
+ e.getMessage().contains("Addressing Property is not
present"));
+ }
+
+ }
+}
\ No newline at end of file
Added:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http-addr-server.xml
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http-addr-server.xml
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http-addr-server.xml 2011-05-24
21:08:25 UTC (rev 14425)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+
http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans
xmlns="http://www.springframework.org/schema/beans"
+
xmlns:jaxws="http://cxf.apache.org/jaxws"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ 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">
+
+ <bean id="org.apache.cxf.ws.policy.PolicyEngine"
class="org.apache.cxf.ws.policy.PolicyEngineImpl">
+ <property name="bus" ref="cxf"/>
+ <property name="enabled" value="true"/>
+ </bean>
+
+ <jaxws:endpoint
+
name="{http://cxf.apache.org/greeter_control}GreeterPort"
+ createdFromAPI="true"
+
wsdlLocation="org/apache/cxf/systest/ws/policy/http_server_greeter_addr.wsdl"/>
+</beans>
\ No newline at end of file
Added:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter_addr.wsdl
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter_addr.wsdl
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter_addr.wsdl 2011-05-24
21:08:25 UTC (rev 14425)
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+
http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<wsdl:definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+
xmlns:tns="http://cxf.apache.org/greeter_control"
+
xmlns:x1="http://cxf.apache.org/greeter_control/types"
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
+
xmlns:wsp="http://www.w3.org/ns/ws-policy"
+
targetNamespace="http://cxf.apache.org/greeter_control"
name="HelloWorld">
+ <wsdl:types>
+ <schema
targetNamespace="http://cxf.apache.org/greeter_control/types"
+
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
+ <element name="sayHi">
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType"
type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType"
type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType"
type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType"
type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="pingMe">
+ <complexType/>
+ </element>
+ <element name="pingMeResponse">
+ <complexType/>
+ </element>
+ <element name="faultDetail">
+ <complexType>
+ <sequence>
+ <element name="minor"
type="xsd:short"/>
+ <element name="major"
type="xsd:short"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part element="x1:sayHi" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part element="x1:sayHiResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part element="x1:greetMe" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part element="x1:greetMeResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeOneWayRequest">
+ <wsdl:part element="x1:greetMeOneWay" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeRequest">
+ <wsdl:part name="in" element="x1:pingMe"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeResponse">
+ <wsdl:part name="out" element="x1:pingMeResponse"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeFault">
+ <wsdl:part name="faultDetail"
element="x1:faultDetail"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest"
name="sayHiRequest"/>
+ <wsdl:output message="tns:sayHiResponse"
name="sayHiResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <wsdl:input message="tns:greetMeRequest"
name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse"
name="greetMeResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <wsdl:input message="tns:greetMeOneWayRequest"
name="greetMeOneWayRequest"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="pingMe">
+ <wsdl:input name="pingMeRequest"
message="tns:pingMeRequest"/>
+ <wsdl:output name="pingMeResponse"
message="tns:pingMeResponse"/>
+ <wsdl:fault name="pingMeFault"
message="tns:pingMeFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="GreeterSOAPBinding"
type="tns:Greeter">
+ <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsp:Policy>
+ <wsp:PolicyReference URI="#WSAM_Addressing_Policy"/>
+ </wsp:Policy>
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHiRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHiResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeOneWayRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+
+ <wsdl:operation name="pingMe">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="pingMeFault">
+ <soap:fault name="pingMeFault" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="BasicGreeterService">
+ <wsdl:port binding="tns:GreeterSOAPBinding"
name="GreeterPort">
+ <soap:address
location="http://localhost:9020/SoapContext/GreeterPort"/>
+ </wsdl:port>
+ </wsdl:service>
+
+
+ <wsp:Policy wsu:Id="WSAM_Addressing_Policy"
+
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-w...
+ <wsam:Addressing>
+ <wsp:Policy />
+ </wsam:Addressing>
+ </wsp:Policy>
+</wsdl:definitions>
+