TUSCANY-2322: print valid XML syntax for BPEL partnerLinkType element in WSDL, and add an itest module to check ?wsdl output

git-svn-id: https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk@1096233 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/itest/pom.xml b/itest/pom.xml
index de22d1b..d89d986 100644
--- a/itest/pom.xml
+++ b/itest/pom.xml
@@ -141,6 +141,7 @@
                 <module>workspace-manager</module>
                 <module>wsdl</module>
                 <module>wsdlgen</module>
+                <module>wsdlgen-runtime</module>
                 <module>wsdlgen-verify</module>
                 <module>wsdlless</module>
                 <module>wsdl2java</module>
diff --git a/itest/wsdlgen-runtime/pom.xml b/itest/wsdlgen-runtime/pom.xml
new file mode 100644
index 0000000..226a0dc
--- /dev/null
+++ b/itest/wsdlgen-runtime/pom.xml
@@ -0,0 +1,116 @@
+<?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.    

+-->

+<project>

+    <modelVersion>4.0.0</modelVersion>

+    <parent>

+        <groupId>org.apache.tuscany.sca</groupId>

+        <artifactId>tuscany-sca</artifactId>

+        <version>1.7-SNAPSHOT</version>

+        <relativePath>../../pom.xml</relativePath>

+    </parent>

+    <artifactId>itest-wsdlgen-runtime</artifactId>

+    <name>Apache Tuscany SCA iTest runtime WSDL generation</name>

+

+    <dependencies>

+        <dependency>

+            <groupId>org.apache.tuscany.sca</groupId>

+            <artifactId>tuscany-host-embedded</artifactId>

+            <version>1.7-SNAPSHOT</version>

+        </dependency>

+

+        <dependency>

+            <groupId>org.apache.tuscany.sca</groupId>

+            <artifactId>tuscany-implementation-java-runtime</artifactId>

+            <version>1.7-SNAPSHOT</version>

+            <scope>runtime</scope>

+        </dependency>

+

+        <dependency>

+            <groupId>org.apache.tuscany.sca</groupId>

+            <artifactId>tuscany-binding-ws-axis2</artifactId>

+            <version>1.7-SNAPSHOT</version>

+            <scope>runtime</scope>

+        </dependency>    

+

+        <dependency>

+            <groupId>org.apache.tuscany.sca</groupId>

+            <artifactId>tuscany-implementation-bpel-ode</artifactId>

+            <version>1.7-SNAPSHOT</version>

+            <scope>runtime</scope>

+        </dependency>

+

+        <dependency>

+            <groupId>org.apache.tuscany.sca</groupId>

+            <artifactId>tuscany-host-jetty</artifactId>

+            <version>1.7-SNAPSHOT</version>

+            <scope>runtime</scope>            

+        </dependency>

+

+        <dependency>

+            <groupId>junit</groupId>

+            <artifactId>junit</artifactId>

+            <version>4.5</version>

+            <scope>test</scope>

+        </dependency>

+    </dependencies>

+    

+    <build>

+       <finalName>${artifactId}</finalName>

+        <plugins>

+            <plugin>

+                <groupId>org.apache.maven.plugins</groupId>

+                <artifactId>maven-surefire-plugin</artifactId>

+                <!-- http://jira.codehaus.org/browse/SUREFIRE-322 -->

+                <version>2.3.1</version>

+                <configuration>

+                    <useFile>false</useFile>

+                    <trimStackTrace>false</trimStackTrace>

+                    <useSystemClassLoader>true</useSystemClassLoader>

+                </configuration>

+            </plugin>

+            <plugin>

+                <groupId>org.apache.maven.plugins</groupId>

+                <artifactId>maven-dependency-plugin</artifactId>

+                <executions>

+                    <execution>

+                        <id>unpack</id>

+                        <phase>compile</phase>

+                        <goals>

+                            <goal>unpack</goal>

+                        </goals>

+                        <configuration>

+                            <artifactItems>

+                                <artifactItem>

+                                    <groupId>org.apache.ode</groupId>

+                                    <artifactId>ode-dao-jpa-ojpa-derby</artifactId>

+                                    <version>1.1.1</version>

+                                    <type>zip</type>

+                                    <overWrite>true</overWrite>

+                                    <outputDirectory>${project.build.directory}/classes/</outputDirectory>

+                                </artifactItem>

+                            </artifactItems>

+                        </configuration>

+                    </execution>

+                </executions>

+            </plugin>

+        </plugins>

+    </build>

+

+</project>

diff --git a/itest/wsdlgen-runtime/src/main/java/wsdlgen/Account.java b/itest/wsdlgen-runtime/src/main/java/wsdlgen/Account.java
new file mode 100644
index 0000000..e3eb4ff
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/java/wsdlgen/Account.java
@@ -0,0 +1,34 @@
+/*

+ * 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 wsdlgen;

+

+import org.osoa.sca.annotations.Remotable;

+

+/**

+ * Test ?wsdl works and that the returned WSDL has the correct endpoint

+ *

+ * @version $Rev$ $Date$

+ */

+@Remotable

+public interface Account {

+    

+    CustomerProfileData getCustomerProfile(String loginID);

+

+}

diff --git a/itest/wsdlgen-runtime/src/main/java/wsdlgen/CustomerProfileData.java b/itest/wsdlgen-runtime/src/main/java/wsdlgen/CustomerProfileData.java
new file mode 100644
index 0000000..af704da
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/java/wsdlgen/CustomerProfileData.java
@@ -0,0 +1,103 @@
+/*

+ * 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 wsdlgen;

+

+/**

+ * Test ?wsdl works and that the returned WSDL has the correct endpoint

+ *

+ * @version $Rev$ $Date$

+ */

+public class CustomerProfileData {

+    

+    private String firstName;

+    private String lastName;

+    private String address;

+    private String email;

+    private String loginID;

+    private String password;

+    private int id;

+

+    public CustomerProfileData(String loginID) {

+        firstName = "John";

+        lastName = "Doe";

+        address = "345 Main Street";

+        email = "john@doe.org";

+        this.loginID = loginID;

+        password = "hello";

+        id = 1234;

+    }

+

+    public String getFirstName() {

+        return firstName;

+    }

+

+    public void setFirstName(String firstName) {

+        this.firstName = firstName;

+    }

+

+    public String getLastName() {

+        return lastName;

+    }

+

+    public void setLastName(String firstName) {

+        this.lastName = lastName;

+    }

+

+    public String getAddress() {

+        return address;

+    }

+

+    public void setAddress(String address) {

+        this.address = address;

+    }

+

+    public String getEmail() {

+        return email;

+    }

+

+    public void setEmail(String email) {

+        this.email = email;

+    }

+

+    public String getLoginID() {

+        return loginID;

+    }

+

+    public void setLoginID(String loginID) {

+        this.loginID = loginID;

+    }

+

+    public String getPassword() {

+        return password;

+    }

+

+    public void setPassword(String password) {

+        this.password = password;

+    }

+

+    public int getId() {

+        return id;

+    }

+

+    public void setId(int id) {

+        this.id = id;

+    }

+

+}

diff --git a/itest/wsdlgen-runtime/src/main/java/wsdlgen/impl/AccountImpl.java b/itest/wsdlgen-runtime/src/main/java/wsdlgen/impl/AccountImpl.java
new file mode 100644
index 0000000..3695487
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/java/wsdlgen/impl/AccountImpl.java
@@ -0,0 +1,36 @@
+/*

+ * 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 wsdlgen.impl;

+

+import wsdlgen.Account;

+import wsdlgen.CustomerProfileData;

+

+/**

+ * Test ?wsdl works and that the returned WSDL has the correct endpoint

+ *

+ * @version $Rev$ $Date$

+ */

+public class AccountImpl implements Account {

+

+    public CustomerProfileData getCustomerProfile(String loginID) {

+        return new CustomerProfileData(loginID);

+    }

+

+}

diff --git a/itest/wsdlgen-runtime/src/main/resources/jupiter.bpel b/itest/wsdlgen-runtime/src/main/resources/jupiter.bpel
new file mode 100644
index 0000000..0f145c7
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/resources/jupiter.bpel
@@ -0,0 +1,48 @@
+<process name="Jupiter"

+    targetNamespace="http://jupiter.ptg.company.com/jupiter"

+    xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"

+    xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"

+    xmlns:tns="http://jupiter.ptg.company.com/jupiter"

+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"

+    xmlns:mw="http://jupiter.ptg.company.com/jupiter.wsdl"

+    queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"

+    expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">

+

+  <import location="wsdl/jupiter.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"

+     namespace="http://jupiter.ptg.company.com/jupiter.wsdl"/>

+

+   <partnerLinks>

+      <partnerLink name="jupiterPartnerLink" partnerLinkType="mw:JupiterPartnerLinkType" myRole="me" />

+   </partnerLinks>

+    

+   <variables>

+     <variable name="myVar" messageType="mw:HelloMessage"/>

+     <variable name="tmpVar" type="xsd:string"/>

+   </variables>

+

+   <sequence>

+       <receive

+          name="start"

+          partnerLink="jupiterPartnerLink"

+          portType="mw:JupiterPortType"

+          operation="hello"

+          variable="myVar"

+          createInstance="yes"/>

+

+      <assign name="assign1">

+          <copy>

+              <from variable="myVar" part="TestPart"/>

+              <to variable="tmpVar"/>

+          </copy>

+          <copy>

+              <from>concat($tmpVar,' World')</from>

+              <to variable="myVar" part="TestPart"/>

+          </copy>

+      </assign>

+       <reply name="end"  

+              partnerLink="jupiterPartnerLink"

+              portType="mw:JupiterPortType" 

+              operation="hello"

+              variable="myVar"/>

+   </sequence>

+</process>

diff --git a/itest/wsdlgen-runtime/src/main/resources/jupiter.composite b/itest/wsdlgen-runtime/src/main/resources/jupiter.composite
new file mode 100644
index 0000000..beebeee
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/resources/jupiter.composite
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"

+           targetNamespace="http://jupiter.ptg.company.com"

+           xmlns:mw="http://jupiter.ptg.company.com"

+		   xmlns:hns="http://jupiter.ptg.company.com/jupiter"

+           name="jupiter">

+

+    <component name="BPELHelloWorldComponent">

+        <implementation.bpel process="hns:Jupiter"/>

+        <service name="jupiterPartnerLink">

+			<interface.wsdl interface="http://jupiter.ptg.company.com/jupiter.wsdl#wsdl.interface(JupiterPortType)" />

+            <binding.ws uri="http://localhost:8085/BPELHelloWorldComponent" />

+        </service>

+	</component>

+    

+</composite>

diff --git a/itest/wsdlgen-runtime/src/main/resources/test-wsdl-import.composite b/itest/wsdlgen-runtime/src/main/resources/test-wsdl-import.composite
new file mode 100644
index 0000000..1f81047
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/resources/test-wsdl-import.composite
@@ -0,0 +1,31 @@
+<?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://accounts"

+           name="test-import">

+

+    <component name="Account">

+		<implementation.java class="wsdlgen.impl.AccountImpl" />

+        <service name="Account">

+            <binding.ws wsdlElement="http://account2#wsdl.port(AccountService/AccountSoapPort)" />

+        </service>

+    </component>

+

+</composite>

diff --git a/itest/wsdlgen-runtime/src/main/resources/wsdl/jupiter.wsdl b/itest/wsdlgen-runtime/src/main/resources/wsdl/jupiter.wsdl
new file mode 100644
index 0000000..91e1ef2
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/resources/wsdl/jupiter.wsdl
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8" ?>

+<wsdl:definitions 

+    targetNamespace="http://jupiter.ptg.company.com/jupiter.wsdl"

+    xmlns="http://schemas.xmlsoap.org/wsdl/"

+    xmlns:tns="http://jupiter.ptg.company.com/jupiter.wsdl"

+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 

+    xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"

+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"

+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

+    xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"

+    xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">

+    

+    <wsdl:types>

+        <schema elementFormDefault="qualified" 

+           targetNamespace="http://jupiter.ptg.company.com/jupiter.wsdl" 

+           xmlns="http://www.w3.org/2001/XMLSchema">

+

+            <element name="hello">

+                <complexType>

+                    <sequence>

+                        <element name="message" type="xsd:string"/>

+                    </sequence>

+                </complexType>

+            </element>            

+        </schema>

+    </wsdl:types>

+    

+    <wsdl:message name="HelloMessage">

+        <wsdl:part element="tns:hello" name="TestPart"/>

+    </wsdl:message>

+    

+    <wsdl:portType name="JupiterPortType">

+        <wsdl:operation name="hello">

+            <wsdl:input message="tns:HelloMessage" name="TestIn"/>

+            <wsdl:output message="tns:HelloMessage" name="TestOut"/>

+        </wsdl:operation>    

+    </wsdl:portType>

+    

+

+    <wsdl:binding name="JupiterSoapBinding" type="tns:JupiterPortType">

+        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

+        <wsdl:operation name="hello">

+            <wsdlsoap:operation soapAction=""/>

+            <wsdl:input name="TestIn">

+                <wsdlsoap:body use="literal"/>

+            </wsdl:input>

+            <wsdl:output name="TestOut">

+                <wsdlsoap:body use="literal"/>

+            </wsdl:output>

+        </wsdl:operation>

+    </wsdl:binding>    

+    

+    <wsdl:service name="JupiterService">

+		<wsdl:port name="JupiterPort" binding="tns:JupiterSoapBinding">

+     		<soap:address location="http://localhost:8085/ode/processes/helloWorld"/>

+		</wsdl:port>

+    </wsdl:service>

+    

+   <plnk:partnerLinkType name="JupiterPartnerLinkType">

+       <plnk:role name="me" portType="tns:JupiterPortType"/>

+       <plnk:role name="you" portType="tns:JupiterPortType"/>

+   </plnk:partnerLinkType>

+</wsdl:definitions>
\ No newline at end of file
diff --git a/itest/wsdlgen-runtime/src/main/resources/wsdl/test-import-nested.wsdl b/itest/wsdlgen-runtime/src/main/resources/wsdl/test-import-nested.wsdl
new file mode 100644
index 0000000..842ac1b
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/resources/wsdl/test-import-nested.wsdl
@@ -0,0 +1,70 @@
+<?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://account3"

+                  xmlns:tns="http://account3"

+                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

+                  xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"

+                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"

+	              name="test-import-nested">

+

+    <wsdl:types>

+        <xsd:schema elementFormDefault="qualified"

+                    targetNamespace="http://account3"

+                    xmlns:account="http://accounts"

+                    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

+

+            <xsd:import namespace="http://accounts" schemaLocation="/xsd/customerdefs.xsd" />

+

+            <xsd:element name="getCustomerProfile">

+                <xsd:complexType>

+                    <xsd:sequence>

+                        <xsd:element name="loginID" type="xsd:string" />

+                    </xsd:sequence>

+                </xsd:complexType>

+            </xsd:element>

+

+            <xsd:element name="getCustomerProfileResponse">

+                <xsd:complexType>

+                    <xsd:sequence>

+                        <xsd:element name="customerProfile"

+                            type="account:CustomerProfileData" />

+                    </xsd:sequence>

+                </xsd:complexType>

+            </xsd:element>

+            

+        </xsd:schema>

+    </wsdl:types>

+

+    <wsdl:message name="getCustomerProfileRequest">

+        <wsdl:part element="tns:getCustomerProfile" name="parameters" />

+    </wsdl:message>

+

+    <wsdl:message name="getCustomerProfileResponse">

+        <wsdl:part element="tns:getCustomerProfileResponse" name="parameters" />

+    </wsdl:message>

+

+    <wsdl:portType name="Account">

+        <wsdl:operation name="getCustomerProfile">

+            <wsdl:input message="tns:getCustomerProfileRequest" name="getCustomerProfileRequest" />

+            <wsdl:output message="tns:getCustomerProfileResponse" name="getCustomerProfileResponse" />

+        </wsdl:operation>

+    </wsdl:portType>

+

+</wsdl:definitions>

diff --git a/itest/wsdlgen-runtime/src/main/resources/wsdl/test-import.wsdl b/itest/wsdlgen-runtime/src/main/resources/wsdl/test-import.wsdl
new file mode 100644
index 0000000..f3446c4
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/resources/wsdl/test-import.wsdl
@@ -0,0 +1,55 @@
+<?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://account2"
+                  xmlns:tns="http://account2"
+                  xmlns:account3="http://account3"
+                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+                  xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+                  xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/"
+	              name="test-import">
+
+    <wsdl:import namespace="http://account3" location="/wsdl/test-import-nested.wsdl" />
+
+    <wsdl:binding name="AccountSoapBinding" type="account3:Account">
+        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+        <wsdl:operation name="getCustomerProfile">
+            <wsdlsoap:operation soapAction="" />
+            <wsdl:input name="getCustomerProfileRequest">
+                <wsdlsoap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output name="getCustomerProfileResponse">
+                <wsdlsoap:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+
+    <wsdl:service name="AccountService">
+        <wsdl:port binding="tns:AccountSoapBinding" name="AccountSoapPort">
+            <wsdlsoap:address location="http://localhost:8086/AccountService" />
+        </wsdl:port>
+    </wsdl:service>
+
+    <plnk:partnerLinkType name="AccountPartnerLinkType">
+        <plnk:role name="me" portType="account3:Account" />
+        <plnk:role name="you" portType="account3:Account" />
+    </plnk:partnerLinkType>
+
+</wsdl:definitions>
diff --git a/itest/wsdlgen-runtime/src/main/resources/xsd/customerdata.xsd b/itest/wsdlgen-runtime/src/main/resources/xsd/customerdata.xsd
new file mode 100644
index 0000000..f09ed09
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/resources/xsd/customerdata.xsd
@@ -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.    

+-->

+<xsd:schema elementFormDefault="qualified"

+            targetNamespace="http://accounts"

+            xmlns:xsd="http://www.w3.org/2001/XMLSchema">

+

+    <xsd:complexType name="CustomerProfileData">

+        <xsd:sequence>

+            <xsd:element name="firstName" type="xsd:string" />

+            <xsd:element name="lastName" type="xsd:string" />

+            <xsd:element name="address" type="xsd:string" />

+            <xsd:element name="email" type="xsd:string" />

+            <xsd:element name="loginID" type="xsd:string" />

+            <xsd:element name="password" type="xsd:string" />

+            <xsd:element name="id" type="xsd:int" />

+        </xsd:sequence>

+    </xsd:complexType>

+    

+</xsd:schema>

diff --git a/itest/wsdlgen-runtime/src/main/resources/xsd/customerdefs.xsd b/itest/wsdlgen-runtime/src/main/resources/xsd/customerdefs.xsd
new file mode 100644
index 0000000..f312920
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/resources/xsd/customerdefs.xsd
@@ -0,0 +1,27 @@
+<?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.    

+-->

+<xsd:schema elementFormDefault="qualified"

+            targetNamespace="http://accounts"

+            xmlns:xsd="http://www.w3.org/2001/XMLSchema">

+

+    <xsd:include schemaLocation="customerdata.xsd" />

+    <xsd:include schemaLocation="/xsd/customerinfo.xsd" />

+    

+</xsd:schema>

diff --git a/itest/wsdlgen-runtime/src/main/resources/xsd/customerinfo.xsd b/itest/wsdlgen-runtime/src/main/resources/xsd/customerinfo.xsd
new file mode 100644
index 0000000..7c903c6
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/main/resources/xsd/customerinfo.xsd
@@ -0,0 +1,31 @@
+<?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.    

+-->

+<xsd:schema elementFormDefault="qualified"

+            targetNamespace="http://accounts"

+            xmlns:xsd="http://www.w3.org/2001/XMLSchema">

+

+    <xsd:complexType name="CustomerProfileInfo">

+        <xsd:sequence>

+            <xsd:element name="firstName" type="xsd:string" />

+            <xsd:element name="lastName" type="xsd:string" />

+        </xsd:sequence>

+    </xsd:complexType>

+    

+</xsd:schema>

diff --git a/itest/wsdlgen-runtime/src/test/java/wsdlgen/JupiterBPELTestCase.java b/itest/wsdlgen-runtime/src/test/java/wsdlgen/JupiterBPELTestCase.java
new file mode 100644
index 0000000..d82ed47
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/test/java/wsdlgen/JupiterBPELTestCase.java
@@ -0,0 +1,103 @@
+/*

+ * 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 wsdlgen;

+

+import java.io.BufferedReader;

+import java.io.InputStream;

+import java.io.InputStreamReader;

+import java.net.URL;

+import java.util.List;

+

+import javax.wsdl.Definition;

+import javax.wsdl.Port;

+import javax.wsdl.Service;

+import javax.wsdl.extensions.soap.SOAPAddress;

+import javax.wsdl.factory.WSDLFactory;

+import javax.wsdl.xml.WSDLReader;

+import javax.xml.namespace.QName;

+

+import junit.framework.TestCase;

+

+import org.apache.tuscany.sca.host.embedded.SCADomain;

+

+/**

+ * Test ?wsdl works for WSDL with BPEL partnerLinkType definition

+ *

+ * @version $Rev$ $Date$

+ */

+public class JupiterBPELTestCase extends TestCase {

+

+    private SCADomain domain;

+

+    /**

+     * Tests ?wsdl works and returns the correct port endpoint from the WSDL

+     */

+    public void testBPELPortEndpoint() throws Exception {

+        String endpoint = "http://localhost:8085/BPELHelloWorldComponent";

+        String serviceNS = "http://jupiter.ptg.company.com/BPELHelloWorldComponent/jupiterPartnerLink";

+        String serviceName = "JupiterPortTypeService";

+        String portName = "JupiterPortTypePort";

+

+        printWSDL(endpoint + "?wsdl");

+        printWSDL(endpoint + "?wsdl=wsdl/jupiter.wsdl");

+

+        WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();

+        wsdlReader.setFeature("javax.wsdl.verbose", false);

+        wsdlReader.setFeature("javax.wsdl.importDocuments", true);

+

+        Definition definition = wsdlReader.readWSDL(endpoint + "?wsdl");

+        assertNotNull(definition);

+        Service service = definition.getService(new QName(serviceNS, serviceName));

+        Port port = service.getPort(portName);

+        String address = getAddress(port);

+

+        assertEquals(endpoint, address);

+    }

+

+    private void printWSDL(String url) throws Exception {

+        InputStream inp = new URL(url).openStream();

+        BufferedReader br = new BufferedReader(new InputStreamReader(inp));

+        String line;

+        while((line = br.readLine()) != null) {

+            System.out.println(line);

+        }

+        br.close();

+    }

+

+    private String getAddress(Port port) {

+        List wsdlPortExtensions = port.getExtensibilityElements();

+        for (final Object extension : wsdlPortExtensions) {

+            if (extension instanceof SOAPAddress) {

+                return ((SOAPAddress) extension).getLocationURI();

+            }

+        }

+        throw new RuntimeException("no SOAPAddress");

+    }

+

+    @Override

+    protected void setUp() throws Exception {

+        domain = SCADomain.newInstance("jupiter.composite");

+    }

+

+    @Override

+    protected void tearDown() throws Exception {

+        domain.close();

+    }

+}

diff --git a/itest/wsdlgen-runtime/src/test/java/wsdlgen/WSDLImportTestCase.java b/itest/wsdlgen-runtime/src/test/java/wsdlgen/WSDLImportTestCase.java
new file mode 100644
index 0000000..7b6d4f3
--- /dev/null
+++ b/itest/wsdlgen-runtime/src/test/java/wsdlgen/WSDLImportTestCase.java
@@ -0,0 +1,102 @@
+/*

+ * 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 wsdlgen;

+

+import java.io.BufferedReader;

+import java.io.InputStream;

+import java.io.InputStreamReader;

+import java.net.URL;

+import java.util.List;

+

+import javax.wsdl.Definition;

+import javax.wsdl.Port;

+import javax.wsdl.Service;

+import javax.wsdl.extensions.soap.SOAPAddress;

+import javax.wsdl.factory.WSDLFactory;

+import javax.wsdl.xml.WSDLReader;

+import javax.xml.namespace.QName;

+

+import junit.framework.TestCase;

+

+import org.apache.tuscany.sca.host.embedded.SCADomain;

+

+/**

+ * Test ?wsdl works for WSDL with <wsdl:import>

+ *

+ * @version $Rev$ $Date$

+ */

+public class WSDLImportTestCase extends TestCase {

+

+    private SCADomain domain;

+

+    /**

+     * Tests ?wsdl works and returns the correct port endpoint from the WSDL

+     */

+    public void testWSDLImportPortEndpoint() throws Exception {

+        String endpoint = "http://localhost:8086/AccountService";

+        String serviceNS = "http://account2/Account/Account";

+        String serviceName = "AccountService";

+        String portName = "AccountSoapPort";

+

+        printWSDL(endpoint + "?wsdl");

+

+        WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();

+        wsdlReader.setFeature("javax.wsdl.verbose", false);

+        wsdlReader.setFeature("javax.wsdl.importDocuments", true);

+

+        Definition definition = wsdlReader.readWSDL(endpoint + "?wsdl");

+        assertNotNull(definition);

+        Service service = definition.getService(new QName(serviceNS, serviceName));

+        Port port = service.getPort(portName);

+        String address = getAddress(port);

+

+        assertEquals(endpoint, address);

+    }

+

+    private void printWSDL(String url) throws Exception {

+        InputStream inp = new URL(url).openStream();

+        BufferedReader br = new BufferedReader(new InputStreamReader(inp));

+        String line;

+        while((line = br.readLine()) != null) {

+            System.out.println(line);

+        }

+        br.close();

+    }

+

+    private String getAddress(Port port) {

+        List wsdlPortExtensions = port.getExtensibilityElements();

+        for (final Object extension : wsdlPortExtensions) {

+            if (extension instanceof SOAPAddress) {

+                return ((SOAPAddress) extension).getLocationURI();

+            }

+        }

+        throw new RuntimeException("no SOAPAddress");

+    }

+

+    @Override

+    protected void setUp() throws Exception {

+        domain = SCADomain.newInstance("test-wsdl-import.composite");

+    }

+

+    @Override

+    protected void tearDown() throws Exception {

+        domain.close();

+    }

+}

diff --git a/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java b/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java
index 13203d4..67fd568 100644
--- a/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java
+++ b/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java
@@ -58,16 +58,17 @@
 		BPELPartnerLinkTypeExt thePLinkType = (BPELPartnerLinkTypeExt) theElement;

 		QName theType = thePLinkType.getElementType();

 

-		writer.println("<" + theType.toString() +

+		writer.println("<" + theType.getPrefix() + ":" + localName +

 				       " name=\"" + thePLinkType.getName() + "\">");

 		for( int i = 0; i < 2; i++ ) {

 			if( thePLinkType.getRoleName( i ) != null ) {

-				writer.println( "<" + theType.getPrefix() + ":role"

+				writer.println( "<" + theType.getPrefix() + ":" + roleName

 						       + " name=\"" + thePLinkType.getRoleName(i) + "\" portType=\""

-						       + thePLinkType.getRolePortType(i) + "\">");

+						       + thePLinkType.getRolePortType(i).getPrefix() + ":"

+                               + thePLinkType.getRolePortType(i).getLocalPart() + "\"/>");

 			} // end if

 		} // end for

-		writer.println("</" + theType.toString() + ">");

+		writer.println("</" + theType.getPrefix() + ":" + localName + ">");

 	} // end marshall

 

 	/**

@@ -89,7 +90,7 @@
 		// Check that this elementType really is a partnerLinkType element

 		if( !elementType.getLocalPart().equals(localName) ) return null;

 		BPELPartnerLinkTypeExt theExtension = new BPELPartnerLinkTypeExt();

-		theExtension.setElementType(elementType);

+        theExtension.setElementType(getQNameValue(def, theElement.getTagName()));

 		theExtension.setName( theElement.getAttribute("name") );

 

 		// Fetch the child "role" elements