Author: gnodet
Date: Tue Oct 31 05:52:55 2006
New Revision: 469483

URL: http://svn.apache.org/viewvc?view=rev&rev=469483
Log:
SM-727: Schema import problem on jsr181

Modified:
    
incubator/servicemix/branches/servicemix-3.0/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java
    
incubator/servicemix/branches/servicemix-3.0/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/xfire/JbiProxy.java

Modified: 
incubator/servicemix/branches/servicemix-3.0/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.0/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java?view=diff&rev=469483&r1=469482&r2=469483
==============================================================================
--- 
incubator/servicemix/branches/servicemix-3.0/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java
 (original)
+++ 
incubator/servicemix/branches/servicemix-3.0/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java
 Tue Oct 31 05:52:55 2006
@@ -41,6 +41,7 @@
 
 import org.apache.servicemix.common.Endpoint;
 import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.common.tools.wsdl.WSDLFlattener;
 import org.apache.servicemix.common.xbean.XBeanServiceUnit;
 import org.apache.servicemix.jsr181.xfire.JbiFaultSerializer;
 import org.apache.servicemix.jsr181.xfire.ServiceFactoryHelper;
@@ -236,7 +237,8 @@
             } else if (!interfaceName.equals(wsdlPortType.getQName())) {
                 throw new InvalidParameterException("The name of the PortType 
defined by the deployed wsdl does not match the interface name of the jbi 
endpoint");
             }
-            // Create the DOM document 
+            // Create the DOM document
+            definition = new 
WSDLFlattener(definition).getDefinition(interfaceName); 
             description = 
WSDLFactory.newInstance().newWSDLWriter().getDocument(definition);
         }
         
@@ -268,36 +270,7 @@
         // generate one
         if (this.description == null) {
             this.description = generateWsdl();
-        
-            // If the both interfaceName and serviceName are provided with non 
matching namespaces,
-            // the generated wsdl is bad. We have to keep only the port type 
definition.
-            if (this.service != null && interfaceName != null &&
-                
!this.service.getNamespaceURI().equals(interfaceName.getNamespaceURI())) {
-                // Parse the WSDL
-                WSDLReader reader = WSDLFactory.newInstance().newWSDLReader(); 
-                reader.setFeature(Constants.FEATURE_VERBOSE, false);
-                definition = reader.readWSDL(null, description);
-                // Get the service and port definition
-                javax.wsdl.Service svc = definition.getService(new 
QName(this.interfaceName.getNamespaceURI(), this.service.getLocalPart()));
-                Port port = svc != null && svc.getPorts().size() == 1 ? (Port) 
svc.getPorts().values().iterator().next() : null;
-                if (port != null) {
-                    // If the endpoint name has not been defined, retrieve it 
now
-                    if (endpoint == null) {
-                        endpoint = port.getName();
-                    }
-                    // Now, remove binding and service infos and change target 
namespace
-                    definition.removeBinding(port.getBinding().getQName());
-                    definition.removeService(svc.getQName());
-                    description = 
WSDLFactory.newInstance().newWSDLWriter().getDocument(definition);
-                }
-            }
-            // Write WSDL
-            if (logger.isTraceEnabled()) {
-                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                
WSDLFactory.newInstance().newWSDLWriter().writeWSDL(definition, baos);
-                logger.trace(baos.toString());
-            }
-        
+
             // Check service name and endpoint name
             QName serviceName = xfireService.getName();
             QName interfName = xfireService.getServiceInfo().getPortType();
@@ -316,7 +289,12 @@
                         ") does not match the service name defined in the 
endpoint spec (" + interfaceName + 
                         "). WSDL description may be unusable.");
             }
-            definition = 
WSDLFactory.newInstance().newWSDLReader().readWSDL(null, description);
+
+            // Parse the WSDL
+            WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+            reader.setFeature(Constants.FEATURE_VERBOSE, false);
+            definition = reader.readWSDL(null, description);
+
             javax.wsdl.Service svc = definition.getService(serviceName);
             if (svc != null) {
                 if (svc.getPorts().values().size() == 1) {
@@ -334,6 +312,17 @@
             }
             if (endpoint == null) {
                 throw new IllegalArgumentException("endpoint name should be 
provided");
+            }
+
+            // Flatten it
+            definition = new 
WSDLFlattener(definition).getDefinition(interfaceName);
+            description = 
WSDLFactory.newInstance().newWSDLWriter().getDocument(definition);
+
+            // Write WSDL
+            if (logger.isTraceEnabled()) {
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                
WSDLFactory.newInstance().newWSDLWriter().writeWSDL(definition, baos);
+                logger.trace(baos.toString());
             }
         }
     }

Modified: 
incubator/servicemix/branches/servicemix-3.0/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/xfire/JbiProxy.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.0/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/xfire/JbiProxy.java?view=diff&rev=469483&r1=469482&r2=469483
==============================================================================
--- 
incubator/servicemix/branches/servicemix-3.0/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/xfire/JbiProxy.java
 (original)
+++ 
incubator/servicemix/branches/servicemix-3.0/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/xfire/JbiProxy.java
 Tue Oct 31 05:52:55 2006
@@ -82,7 +82,7 @@
     public Object getProxy() throws Exception {
         if (proxy == null) {
             ServiceFactory factory = 
ServiceFactoryHelper.findServiceFactory(xfire, serviceClass, null, null);
-            Service service = factory.create(serviceClass, null, 
getDescription(), null);
+            Service service = factory.create(serviceClass, null);
             JBIClient client = new JBIClient(xfire, service);
             if (interfaceName != null) {
                 client.getService().setProperty(JbiChannel.JBI_INTERFACE_NAME, 
interfaceName);


Reply via email to