You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2008/09/01 11:03:05 UTC

svn commit: r690913 - in /tuscany/java/sca: itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/ itest/validation/src/test/java/binding/wsxml/ modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/ modules/bi...

Author: antelder
Date: Mon Sep  1 02:03:03 2008
New Revision: 690913

URL: http://svn.apache.org/viewvc?rev=690913&view=rev
Log:
TUSCANY-2242: Apply patch from Ramkumar Ramalingam for Incorrent port name in wsdlElement leads to NPE

Added:
    tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/
    tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworld.wsdl
    tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworldwsclient.composite
    tuscany/java/sca/itest/validation/src/test/java/binding/wsxml/WsdlPortTypeDoesNotMatchTestCase.java
Modified:
    tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
    tuscany/java/sca/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties

Added: tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworld.wsdl
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworld.wsdl?rev=690913&view=auto
==============================================================================
--- tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworld.wsdl (added)
+++ tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworld.wsdl Mon Sep  1 02:03:03 2008
@@ -0,0 +1,92 @@
+<?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 targetNamespace="http://helloworld" xmlns:tns="http://helloworld" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	name="helloworld">
+
+    <wsdl:types>
+        <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns="http://www.w3.org/2001/XMLSchema">
+
+            <element name="getGreetings">
+                <complexType>
+                    <sequence>
+                        <element name="name" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+
+            <element name="getGreetingsResponse">
+                <complexType>
+                    <sequence>
+                        <element name="getGreetingsReturn" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            
+        </schema>
+    </wsdl:types>
+
+    <wsdl:message name="getGreetingsRequest">
+        <wsdl:part element="tns:getGreetings" name="parameters"/>
+    </wsdl:message>
+
+    <wsdl:message name="getGreetingsResponse">
+        <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+    </wsdl:message>
+
+    <wsdl:portType name="HelloWorld">
+        <wsdl:operation name="getGreetings">
+            <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+            <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
+        </wsdl:operation>
+    </wsdl:portType>
+
+    <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
+        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="getGreetings">
+            <wsdlsoap:operation soapAction=""/>
+            <wsdl:input name="getGreetingsRequest">
+                <wsdlsoap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="getGreetingsResponse">
+                <wsdlsoap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+
+    <wsdl:binding name="HelloWorldSoapJmsBinding" type="tns:HelloWorld">
+        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/jms"/>
+        <wsdl:operation name="getGreetings">
+            <wsdlsoap:operation soapAction=""/>
+            <wsdl:input name="getGreetingsRequest">
+                <wsdlsoap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="getGreetingsResponse">
+                <wsdlsoap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+
+    <wsdl:service name="HelloWorldService">
+        <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
+            <wsdlsoap:address location="http://localhost:8085/HelloWorldService"/>
+        </wsdl:port>
+    </wsdl:service>
+
+</wsdl:definitions>

Added: tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworldwsclient.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworldwsclient.composite?rev=690913&view=auto
==============================================================================
--- tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworldwsclient.composite (added)
+++ tuscany/java/sca/itest/validation/src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworldwsclient.composite Mon Sep  1 02:03:03 2008
@@ -0,0 +1,45 @@
+<?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.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+	targetNamespace="http://helloworld"
+	xmlns:hw="http://helloworld"
+	name="helloworldwsclient">
+    
+    <!-- A component with an embedded reference definition connecting to an external webservice 
+         The wsdl interface for the reference is derived from the information specified by the 'wsdlElement'
+     -->
+    <component name="HelloTuscanyServiceComponent">
+      <implementation.java class="binding.jms.HelloWorldServiceImpl"/>
+      <reference name="helloWorldService">
+        <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort2)"/>
+      </reference>
+    </component>
+    
+    <!-- A component with a reference promoted as a composite reference -->
+    <component name="HelloWorldServiceComponent">
+      <implementation.java class="binding.jms.HelloWorldServiceImpl"/>
+    </component>
+    
+    <reference name="HelloWorldService" promote="HelloWorldServiceComponent/helloWorldService">
+        <interface.java interface="binding.jms.HelloWorldService" />
+        <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort2)"/>
+    </reference>
+
+</composite>

Added: tuscany/java/sca/itest/validation/src/test/java/binding/wsxml/WsdlPortTypeDoesNotMatchTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/validation/src/test/java/binding/wsxml/WsdlPortTypeDoesNotMatchTestCase.java?rev=690913&view=auto
==============================================================================
--- tuscany/java/sca/itest/validation/src/test/java/binding/wsxml/WsdlPortTypeDoesNotMatchTestCase.java (added)
+++ tuscany/java/sca/itest/validation/src/test/java/binding/wsxml/WsdlPortTypeDoesNotMatchTestCase.java Mon Sep  1 02:03:03 2008
@@ -0,0 +1,60 @@
+/*
+ * 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 binding.wsxml;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.logging.impl.DefaultLoggingMonitorImpl;
+
+import domain.CustomCompositeBuilder;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class WsdlPortTypeDoesNotMatchTestCase extends TestCase {
+	
+    private CustomCompositeBuilder customDomain;
+    
+    @Override
+    protected void setUp() throws Exception 
+    {
+        customDomain = CustomCompositeBuilder.getInstance();
+        try {
+             customDomain.loadContribution("src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/helloworldwsclient.composite", 
+                       "TestContribution", "src/main/resources/binding/wsxml/WsdlPortTypeDoesNotMatch/");
+        } catch (Exception ex){
+            //throw ex;
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        //node.stop();
+    }
+
+    public void testCalculator() {
+        Monitor monitor = customDomain.getMonitorInstance();
+        Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
+        
+        assertNotNull(problem);
+        assertEquals("WsdlPortTypeDoesNotMatch", problem.getMessageId()); 
+    }
+}

Modified: tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java?rev=690913&r1=690912&r2=690913&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java (original)
+++ tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java Mon Sep  1 02:03:03 2008
@@ -348,8 +348,12 @@
                     model.setService(service.getElement());
                     if (model.getPortName() != null) {
                         Port port = service.getElement().getPort(model.getPortName());
-                        model.setPort(port);
-                        model.setBinding(port.getBinding());
+                        if (port != null) {
+                            model.setPort(port);
+                            model.setBinding(port.getBinding());
+                        } else {
+                            warning("WsdlPortTypeDoesNotMatch", wsdlDefinition, model.getPortName());
+                        }
                     }
                 } else {
                 	warning("WsdlServiceDoesNotMatch", wsdlDefinition, model.getServiceName());

Modified: tuscany/java/sca/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties?rev=690913&r1=690912&r2=690913&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties (original)
+++ tuscany/java/sca/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties Mon Sep  1 02:03:03 2008
@@ -21,6 +21,8 @@
 InvalidWsdlElementAttr = Invalid WebService binding wsdlElement attribute: {0}
 MustUseWsdlBinding = {0} must use wsdl.binding when using wsa:EndpointReference
 InvalidInterfaceException = Exception creating interface from WSDL for binding: {0}
-WsdlBindingDoesNotMatch = The #wsdl.binding({0}) does not match with the WSDL Definitions 
+WsdlBindingDoesNotMatch = The #wsdl.binding({0}) does not match with the WSDL Definitions
 WsdlServiceDoesNotMatch = The #wsdl.service({0}) does not match with the WSDL Definitions
+WsdlPortTypeDoesNotMatch = The #wsdl.port({0}) does not match with the WSDL Definitions
+