Author: scamp
Date: Tue May 31 08:46:45 2005
New Revision: 179225

URL: http://svn.apache.org/viewcvs?rev=179225&view=rev
Log:
fixes bad name generation when wsdl port has a name with invalid java name 
chars...utilizes xmlbeans NameUtil class

Modified:
    
incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/ResourceDefinitionImpl.java

Modified: 
incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/ResourceDefinitionImpl.java
URL: 
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/ResourceDefinitionImpl.java?rev=179225&r1=179224&r2=179225&view=diff
==============================================================================
--- 
incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/ResourceDefinitionImpl.java
 (original)
+++ 
incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/ResourceDefinitionImpl.java
 Tue May 31 08:46:45 2005
@@ -17,6 +17,7 @@
 
 import org.apache.ws.resource.InvalidWsrfWsdlException;
 import org.apache.ws.resource.ResourceDefinition;
+import org.apache.xmlbeans.impl.common.NameUtil;
 
 import javax.wsdl.Binding;
 import javax.wsdl.Definition;
@@ -45,8 +46,25 @@
     {
         super( def, getResourcePortType( port ), baseUrl);
         m_port = port;
+        m_name = getValidJavaName(port, def.getTargetNamespace());
         m_endpointURL = extractEndpointURL( m_port );
-        m_name = m_port.getName();
+    }
+
+
+
+    /**
+     * Method to ensure the service name (and thereby the generated class 
names)
+     * contain only characters which are valid for Java Class Names...
+     *
+     * Note: If a character is encountered which is not valid, it is replaced 
with an underscore.
+     *
+     * @param port
+     * @param targetNamespace
+     * @return A valid Java name based on the original, only the invalid chars 
are replaced with underscores.
+     */
+    private String getValidJavaName(Port port, String targetNamespace)
+    {
+        return NameUtil.getClassNameFromQName(new QName(targetNamespace, 
m_port.getName()));
     }
 
 
@@ -93,7 +111,7 @@
         return name;
     }
 
-    private String extractEndpointURL( Port port ) throws 
InvalidWsrfWsdlException
+    private String extractEndpointURL(Port port) throws 
InvalidWsrfWsdlException
     {
         String endpointURL = null;
 
@@ -111,7 +129,7 @@
         if ( endpointURL == null )
         {
             throw new InvalidWsrfWsdlException(
-                    "Failed to obtain service endpoint URL from port " + 
m_port.getName() +
+                    "Failed to obtain service endpoint URL from port " + 
m_name +
                     " service's wsdl:port/soap:address/@location attribute" );
         }
         return endpointURL;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to