cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r450735 - in /incubator/cxf/trunk: distribution/src/main/release/samples/mtom/ distribution/src/main/release/samples/mtom/src/demo/mtom/client/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/bindings/soap/src/main/resources/...
Date Thu, 28 Sep 2006 07:28:40 GMT
Author: tli
Date: Thu Sep 28 00:28:39 2006
New Revision: 450735

URL: http://svn.apache.org/viewvc?view=rev&rev=450735
Log:
remove debug code in SoapBindingFactory, Refactor the mtom demo, fix the SchemaValidator.getWsdlUrl()
error on windows platform

Modified:
    incubator/cxf/trunk/distribution/src/main/release/samples/mtom/README.txt
    incubator/cxf/trunk/distribution/src/main/release/samples/mtom/build.xml
    incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/resources/META-INF/cxf/cxf-extension.xml
    incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/mtom/README.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/README.txt?view=diff&rev=450735&r1=450734&r2=450735
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/mtom/README.txt (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/mtom/README.txt Thu Sep 28 00:28:39
2006
@@ -84,10 +84,10 @@
 
 For UNIX (must use forward slashes):
     java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties
-         demo.hw.server.Server &
+         demo.mtom.server.Server &
 
     java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties
-         demo.hw.client.Client ./wsdl/mtom_xop.wsdl
+         demo.mtom.client.Client ./wsdl/mtom_xop.wsdl
 
 The server process starts in the background.  After running the client,
 use the kill command to terminate the server process.
@@ -95,10 +95,10 @@
 For Windows (may use either forward or back slashes):
   start 
     java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties
-         demo.hw.server.Server
+         demo.mtom.server.Server
 
     java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties
-       demo.hw.client.Client .\wsdl\mtom_xop.wsdl
+       demo.mtom.client.Client .\wsdl\mtom_xop.wsdl
 
 A new command windows opens for the server process.  After running the
 client, terminate the server process by issuing Ctrl-C in its command window.
@@ -144,12 +144,12 @@
   For UNIX:
     
     java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties
-         demo.hw.client.Client http://localhost:#/helloworld/cxf/hello_world
+         demo.mtom.client.Client http://localhost:#/mtom/cxf/mime_test
 
   For Windows:
 
     java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties
-       demo.hw.client.Client http://localhost:#/helloworld/cxf/hello_world
+       demo.mtom.client.Client http://localhost:#/mtom/cxf/mime_test
 
 Where # is the TCP/IP port used by the servlet container,
 e.g., 8080.

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/mtom/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/build.xml?view=diff&rev=450735&r1=450734&r2=450735
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/mtom/build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/mtom/build.xml Thu Sep 28 00:28:39
2006
@@ -26,7 +26,7 @@
         <cxfrun classname="demo.mtom.client.Client"
             param1="${basedir}/wsdl/mtom_xop.wsdl" 
             param2="${op}" 
-            param3="${basedir}/src/demo/mtom/client/me.bmp"/>
+            param3="${param}"/>
     </target> 
         
     <target name="server" description="run demo server" depends="build">
@@ -45,7 +45,6 @@
 
     <target name="client-servlet" description="run demo client hitting servlet" depends="build">
         <property name="param" value=""/>
-        <cxfrun classname="demo.mtom.client.Client" param1="${base.url}/mtom/cxf/mime_test"
param2="${op}" 
-		param3="${basedir}/src/demo/mtom/client/me.bmp"/>
+        <cxfrun classname="demo.mtom.client.Client" param1="${base.url}/mtom/cxf/mime_test"
param2="${op}"/>
     </target> 
 </project>

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java?view=diff&rev=450735&r1=450734&r2=450735
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/mtom/src/demo/mtom/client/Client.java
Thu Sep 28 00:28:39 2006
@@ -38,38 +38,36 @@
 
 public final class Client {
 
-    private static final QName SERVICE_NAME 
-        = new QName("http://cxf.apache.org/mime", "HelloService");
+    private static final QName SERVICE_NAME = new QName("http://cxf.apache.org/mime", "HelloService");
 
-    private static final QName PORT_NAME 
-        = new QName("http://cxf.apache.org/mime", "HelloPort");
+    private static final QName PORT_NAME = new QName("http://cxf.apache.org/mime", "HelloPort");
 
     private Client() {
-    } 
+    }
 
     public static void main(String args[]) throws Exception {
 
         Client client = new Client();
-        
-        if (args.length == 0) { 
+
+        if (args.length == 0) {
             System.out.println("please specify wsdl");
-            System.exit(1); 
+            System.exit(1);
         }
         URL wsdlURL;
         File wsdlFile = new File(args[0]);
-        File bmpFile = new File(args[2]);
+
         if (wsdlFile.exists()) {
             wsdlURL = wsdlFile.toURL();
         } else {
             wsdlURL = new URL(args[0]);
-        }        
+        }
         System.out.println(wsdlURL);
 
         HelloService ss = new HelloService(wsdlURL, SERVICE_NAME);
         Hello port = (Hello) ss.getPort(PORT_NAME, Hello.class);
 
         ByteArrayDataSource bads = new ByteArrayDataSource(getResourceStream(wsdlFile),
-                                                           "Application/octet-stream");
+                "Application/octet-stream");
         DataHandler dh = new DataHandler(bads);
         System.out.println("Start test the Soap Message with Attachment!");
         System.out.println("sending out the Client.java file content as attachment to server");
@@ -81,10 +79,9 @@
         for (int i = in.read(); i != -1; i = in.read()) {
             System.out.write(i);
         }
-        System.out.println("finished print the mtom_xop.wsdl content.");        
-        
+        System.out.println("finished print the mtom_xop.wsdl content.");
 
-        InputStream pre = getResourceStream(bmpFile);
+        InputStream pre = client.getClass().getResourceAsStream("me.bmp");
         long fileSize = 0;
         for (int i = pre.read(); i != -1; i = pre.read()) {
             fileSize++;
@@ -93,16 +90,18 @@
         param.value = new byte[(int) fileSize];
         System.out.println("Start test the XML-binary Optimized Packaging!");
         System.out.println("Sending out the me.bmp Image content to server, data size is
" + fileSize);
-        getResourceStream(bmpFile).read(param.value);
-        String target = new String(param.value);
+
+        in = client.getClass().getResourceAsStream("me.bmp");
+        in.read(param.value);
         Holder<String> name = new Holder<String>("call detail");
         port.detail(name, param);
         System.out.println("received byte[] back from server, the size is " + param.value.length);
-        
-        Image image = ImageIO.read(new ByteArrayInputStream(param.value));        
-        System.out.println("build image with the returned byte[] back from server successfully");
 
-        System.exit(0); 
+        Image image = ImageIO.read(new ByteArrayInputStream(param.value));
+        System.out.println("build image with the returned byte[] back from server successfully,
hashCode="
+                + image.hashCode());
+
+        System.exit(0);
     }
 
     private static InputStream getResourceStream(File file) throws Exception {

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?view=diff&rev=450735&r1=450734&r2=450735
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Thu Sep 28 00:28:39 2006
@@ -78,11 +78,7 @@
     
     private Bus bus;
     private Collection<String> activationNamespaces;    
-    
-    public SoapBindingFactory() {
-        System.out.println("Called create soap binding");
-    }
-    
+       
     @Resource
     public void setBus(Bus b) {
         bus = b;

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/resources/META-INF/cxf/cxf-extension.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/resources/META-INF/cxf/cxf-extension.xml?view=diff&rev=450735&r1=450734&r2=450735
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/resources/META-INF/cxf/cxf-extension.xml
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/resources/META-INF/cxf/cxf-extension.xml
Thu Sep 28 00:28:39 2006
@@ -17,6 +17,7 @@
   specific language governing permissions and limitations
   under the License.
 -->
+
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:foo="http://cxf.apache.org/configuration/foo"
@@ -26,6 +27,9 @@
     <bean class="org.apache.cxf.binding.soap.SoapBindingFactory" lazy-init="true">
         <property name="bus">
             <ref bean="cxf"/>
+        </property>
+        <property name="mtomEnabled">
+            <value>false</value>
         </property>
         <property name="activationNamespaces">
             <set>

Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java?view=diff&rev=450735&r1=450734&r2=450735
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
Thu Sep 28 00:28:39 2006
@@ -79,20 +79,29 @@
 
 public class SchemaValidator extends AbstractValidator {
     protected static final Logger LOG = LogUtils.getL7dLogger(SchemaValidator.class);
+
     protected String[] defaultSchemas;
+
     protected String schemaLocation = "./";
 
     private String wsdlsrc;
+
     private String[] xsds;
 
     private DocumentBuilder docBuilder;
+
     private SAXParser saxParser;
+
     private Document schemaValidatedDoc;
+
     private Map<String, Document> wsdlImportDocs;
 
     private Map<String, XmlSchemaCollection> xmlSchemaMap = new HashMap<String,
XmlSchemaCollection>();
+
     private Map<QName, List> msgPartsMap = new HashMap<QName, List>();
+
     private Map<QName, Map> portTypes = new HashMap<QName, Map>();
+
     private Map<QName, QName> bindingMap = new HashMap<QName, QName>();
 
     public SchemaValidator(String schemaDir) throws ToolException {
@@ -101,8 +110,7 @@
         defaultSchemas = getDefaultSchemas();
     }
 
-    public SchemaValidator(String schemaDir, String wsdl, String[] schemas)
-        throws ToolException {
+    public SchemaValidator(String schemaDir, String wsdl, String[] schemas) throws ToolException
{
         super(schemaDir);
         schemaLocation = schemaDir;
         defaultSchemas = getDefaultSchemas();
@@ -143,13 +151,13 @@
         SchemaResourceResolver resourceResolver = new SchemaResourceResolver();
 
         sf.setResourceResolver(resourceResolver);
-      
+
         Source[] sources = new Source[schemas.length];
 
         for (int i = 0; i < schemas.length; i++) {
             // need to validate the schema file
             Document doc = docBuilder.parse(schemas[i]);
-            
+
             DOMSource stream = new DOMSource(doc, schemas[i]);
 
             sources[i] = stream;
@@ -161,17 +169,15 @@
     public boolean validate(InputSource wsdlsource, String[] schemas) throws ToolException
{
         boolean isValid = false;
         try {
-            
+
             Document document = docBuilder.parse(wsdlsource.getSystemId());
-           
-            
+
             Node node = DOMUtils.getChild(document, null);
-            if (node != null 
-                && !"definitions".equals(node.getLocalName())) {
+            if (node != null && !"definitions".equals(node.getLocalName())) {
                 Message msg = new Message("NOT_A_WSDLFILE", LOG, wsdlsource.getSystemId());
                 throw new ToolException(msg);
             }
-            
+
             SAXParserFactory saxFactory = SAXParserFactory.newInstance();
             saxFactory.setFeature("http://xml.org/sax/features/namespaces", true);
             saxParser = saxFactory.newSAXParser();
@@ -223,8 +229,8 @@
 
             this.schemaValidatedDoc = document;
 
-            WSDLElementReferenceValidator wsdlRefValidator = 
-                new WSDLElementReferenceValidator(def, this, xmlEventReader);
+            WSDLElementReferenceValidator wsdlRefValidator = new WSDLElementReferenceValidator(def,
this,
+                    xmlEventReader);
 
             isValid = wsdlRefValidator.isValid();
 
@@ -245,14 +251,14 @@
     }
 
     private void doSchemaValidation(Document doc, NewStackTraceErrorHandler handler) throws
IOException,
-        SAXException {
+            SAXException {
 
         XmlSchemaCollection schemaCol = new XmlSchemaCollection();
         schemaCol.setBaseUri(def.getDocumentBaseURI());
         NodeList nodes = doc.getElementsByTagNameNS(WSDLConstants.NS_XMLNS, "schema");
         for (int x = 0; x < nodes.getLength(); x++) {
             Node schemaNode = nodes.item(x);
-            Element schemaEl = (Element)schemaNode;
+            Element schemaEl = (Element) schemaNode;
             String tns = schemaEl.getAttribute("targetNamespace");
             try {
                 schemaCol.read(schemaEl, tns);
@@ -281,8 +287,7 @@
             if (namespace != null && systemId != null) {
                 Document docImport = docBuilder.parse(systemId);
                 Node node = DOMUtils.getChild(docImport, null);
-                if (node != null 
-                    && !"definitions".equals(node.getLocalName())) {
+                if (node != null && !"definitions".equals(node.getLocalName())) {
                     Message msg = new Message("NOT_A_WSDLFILE", LOG, systemId);
                     throw new ToolException(msg);
                 }
@@ -316,7 +321,7 @@
             FilenameFilter filter = new FilenameFilter() {
                 public boolean accept(File dir, String name) {
                     if (name.toLowerCase().endsWith(".xsd")
-                        && !new File(dir.getPath() + File.separator + name).isDirectory())
{
+                            && !new File(dir.getPath() + File.separator + name).isDirectory())
{
                         return true;
                     }
                     return false;
@@ -324,7 +329,7 @@
             };
 
             File[] files = f.listFiles(filter);
-            
+
             List<String> xsdUrls = new ArrayList<String>(files.length);
             for (File file : files) {
                 try {
@@ -347,13 +352,11 @@
         if (file != null && file.exists()) {
             return file.toURL().toString();
         }
-        // Import may have a relative path
-        int pathIndex = wsdlsrc.lastIndexOf(File.separator);
-        if (pathIndex != -1) {
-            file = new File(wsdlsrc.substring(0, pathIndex + 1) + path);
-            if (file != null && file.exists()) {
-                return file.toURL().toString();
-            }
+        // Import may have a relative path        
+        File wsdlSrcFile = new File(wsdlsrc);
+        file = new File(wsdlSrcFile.getParent(), path);
+        if (file != null && file.exists()) {
+            return file.toURL().toString();
         }
         return null;
     }
@@ -386,8 +389,11 @@
 
 class NewStackTraceErrorHandler implements ErrorHandler {
     protected boolean valid;
+
     private StringBuffer buffer;
+
     private int numErrors;
+
     private List<SAXParseException> errors;
 
     NewStackTraceErrorHandler() {
@@ -444,7 +450,7 @@
 
     private String getErrorMessage(SAXParseException ex) {
         return "line " + ex.getLineNumber() + " column " + ex.getColumnNumber() + " of "
+ ex.getSystemId()
-               + ": " + ex.getMessage();
+                + ": " + ex.getMessage();
     }
 
     private void addError(SAXParseException ex) {
@@ -455,13 +461,13 @@
 
 class SchemaResourceResolver implements LSResourceResolver {
     public LSInput resolveResource(String type, String namespaceURI, String publicId, String
systemId,
-                                   String baseURI) {        
+            String baseURI) {
         String schemaLocation = baseURI.substring(0, baseURI.lastIndexOf("/") + 1);
-        
+
         if (systemId.indexOf("http://") < 0) {
-            systemId =  schemaLocation + systemId; 
+            systemId = schemaLocation + systemId;
         }
-        
+
         LSInput lsin = new LSInputImpl();
         URI uri = null;
         try {
@@ -478,7 +484,7 @@
         } catch (FileNotFoundException e) {
             return null;
         }
-        
+
         lsin.setSystemId(systemId);
         lsin.setByteStream(inputStream);
         return lsin;
@@ -488,11 +494,15 @@
 class LSInputImpl implements LSInput {
 
     protected String fPublicId;
+
     protected String fSystemId;
+
     protected String fBaseSystemId;
 
     protected InputStream fByteStream;
+
     protected Reader fCharStream;
+
     protected String fData;
 
     protected String fEncoding;



Mime
View raw message