cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1126906 - in /cxf/trunk: rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/ systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/
Date Tue, 24 May 2011 07:39:25 GMT
Author: ema
Date: Tue May 24 07:39:24 2011
New Revision: 1126906

URL: http://svn.apache.org/viewvc?rev=1126906&view=rev
Log:
[CXF-3544]:Fix nested policy can not be resolved issue

Added:
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http-addr-server.xml
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter_addr.wsdl
Modified:
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java?rev=1126906&r1=1126905&r2=1126906&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
(original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
Tue May 24 07:39:24 2011
@@ -31,6 +31,7 @@ import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
+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;
@@ -42,6 +43,7 @@ import org.apache.cxf.service.model.Exte
 import org.apache.cxf.service.model.FaultInfo;
 import org.apache.cxf.service.model.MessageInfo;
 import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyProvider;
 import org.apache.cxf.ws.policy.attachment.AbstractPolicyProvider;
 import org.apache.cxf.ws.policy.attachment.reference.LocalServiceModelReferenceResolver;
@@ -169,9 +171,31 @@ public class Wsdl11AttachmentPolicyProvi
         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 (Constants.isPolicyElement(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;
@@ -242,6 +266,7 @@ public class Wsdl11AttachmentPolicyProvi
         if (null != resolved) {
             return resolved;
         }
+        
         ReferenceResolver resolver = new LocalServiceModelReferenceResolver(di, builder);
         resolved = resolver.resolveReference(uri);
         if (null != resolved) {

Added: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java?rev=1126906&view=auto
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java
(added)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/NestedAddressingPolicyTest.java
Tue May 24 07:39:24 2011
@@ -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: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http-addr-server.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http-addr-server.xml?rev=1126906&view=auto
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http-addr-server.xml
(added)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http-addr-server.xml
Tue May 24 07:39:24 2011
@@ -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: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter_addr.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter_addr.wsdl?rev=1126906&view=auto
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter_addr.wsdl
(added)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/http_server_greeter_addr.wsdl
Tue May 24 07:39:24 2011
@@ -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-wssecurity-utility-1.0.xsd">
+		<wsam:Addressing>
+			<wsp:Policy />
+		</wsam:Addressing>
+	</wsp:Policy>
+</wsdl:definitions>
+



Mime
View raw message