JDomTool是否有 没有参数的构造函数,不然newInstance()不能得到对象啊

解决方案 »

  1.   

    还有你可以通过new JDomTool()来定义对象
    为什么又再用一次Class.forName()呢?
      

  2.   

    没有我是常事用两种办法去构造那个类2,3两行我已经注释掉了,就是用这两种方法去构造JDomTool都会报上面那个异常;
      

  3.   

    那你把JDomTool 贴出来看看。。
      

  4.   

    /*
     * Created on 2005-8-23
     */package com.milan.common;import java.io.IOException;
    import java.io.Reader;
    import java.io.Serializable;
    import java.io.StringReader;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.Iterator;
    import java.util.List;import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.JDOMException;
    import org.jdom.input.SAXBuilder;import com.milan.beans.MilanWebServiceCommand;
    import com.milan.exceptions.MilanWebServiceRuntimeException;
    import com.milan.exceptions.MilanXmValidateException;public class JDomTool implements Serializable
    {    /**
         * 将发送过来字符串命令解析成MilanWebServiceCommand对象放在ArrayList中;
         * 
         * @param sCommand
         * @return
         * @throws JDOMException
         * @throws MilanWebServiceRuntimeException
         * @throws 
         */
        public ArrayList parseCommandToObject(String sCommand) throws JDOMException //throws MilanWebServiceRuntimeException
        {        SAXBuilder builder = new SAXBuilder();
            Document doc = null;
            Reader in = new StringReader(sCommand);
            ArrayList listCommand = new ArrayList();
            MilanWebServiceCommand mc = new MilanWebServiceCommand();        try
            {
                doc = builder.build(in);
                Element root = doc.getRootElement();
                List ls = root.getChildren(); //注意此处取出的是root节点下面的一层的Element集合<Command>
                for(Iterator iter = ls.iterator(); iter.hasNext();)
                {                Element elCommand = (Element)iter.next();
                    //取得MilanWebServiceCommandID;
                    mc.setCommandID(elCommand.getAttributeValue("commandID"));                List listChildren = elCommand.getChildren();
                    Element commandElement = null;                for(Iterator iterChildren = listChildren.iterator(); iterChildren.hasNext();)
                    {
                        //为MilanWebServiceCommand对象负值;
                        commandElement = (Element)iterChildren.next();
                        mc.setKoaBeginDate(new Date(commandElement.getChild("koa-begin-date")
                                .getTextTrim()));
                        mc.setKoaCompanyAddress(commandElement.getChild("koa-company-address")
                                .getTextTrim());
                        mc.setKoaCompanyName(commandElement.getChild("koa-company-nam").getTextTrim());
                        mc.setKoaCompanyPos(commandElement.getChild("koa-company-pos").getTextTrim());
                        mc.setKoaCompanyTel(commandElement.getChildTextTrim("koa-company-tel"));
                        mc.setKoaCompanyFax(commandElement.getChildTextTrim("koa-company-fax"));
                        mc.setKoaEndDate(new Date(commandElement.getChildTextTrim("koa-end-date")));
                        mc.setKoaMaxSize(Integer.parseInt(commandElement
                                .getChildTextTrim("koa-max-size")));
                        mc.setKoaMaxUser(Integer.parseInt(commandElement
                                .getChildTextTrim("koa-max-user")));
                        mc.setKoaName(commandElement.getChildTextTrim("koa-name"));
                        mc.setKoaVer(commandElement.getChildTextTrim("koa-ver"));
                        mc.setOnlinenicUserID(commandElement.getChildTextTrim("onlinenic-user-id"));                }
                    mc.validate();
                    listCommand.add(mc);
                }
            }
            catch (IOException e)
            {
                e.printStackTrace();
                //throw new MilanWebServiceRuntimeException(e);
            }
            catch (MilanXmValidateException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }        return listCommand;
        }    public boolean XMLWithSchemaValidate(String sCommand)
        {
            String schema = "CommandSchema.xml";        Reader in = new StringReader(sCommand);        SAXBuilder builder = new SAXBuilder(true);        //指定约束方式为XML schema
            builder.setFeature("http://localhost:9999/milanwebservice/xml/properties/schema/CommandSchema.xml", true);        //导入schema文件
            builder.setProperty("http://localhost:9999/milanwebservice/xml/properties/schema/CommandSchema.xml", schema);        Document doc = null;
            try
            {
                doc = builder.build(in);
                System.out.println("ok");
            }
            catch (JDOMException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            
            System.out.println("NO");
            
            return false;
        }
        
    XMLWithSchemaValidate()这个方法我测试没有成功
      

  5.   

    这个是我测试的代码:
    public class MilanCommandServiceTestCase extends junit.framework.TestCase
    {    public MilanCommandServiceTestCase(java.lang.String name)
        {
            super(name);
        }    public void test1milanServicesExeMilanCommand() throws Exception
        {        com.milan.webservices.client.MilanServicesSoapBindingStub binding;
            try
            {
                binding = (com.milan.webservices.client.MilanServicesSoapBindingStub)new com.milan.webservices.client.MilanCommandServiceLocator()
                        .getmilanServices();
            }
            catch (javax.xml.rpc.ServiceException jre)
            {
                if(jre.getLinkedCause() != null)
                    jre.getLinkedCause().printStackTrace();
                throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: "
                        + jre);
            }
            assertNotNull("binding is null", binding);        //Time out after a minute
            binding.setTimeout(60000);        java.lang.String value = "webWebSercies ok";
            // Test operation
            value = binding.exeMilanCommand(new java.lang.String());
            // TBD - validate results
            System.out.println(value);
        }}
      

  6.   

    测试的代码执行到:value = binding.exeMilanCommand(new java.lang.String());
    报异常;在倒数第6行,(包括挂号,空行和注释)
      

  7.   

    这个是我测试的代码:
    public class MilanCommandServiceTestCase extends junit.framework.TestCase
    {    public MilanCommandServiceTestCase(java.lang.String name)
        {
            super(name);
        }    public void test1milanServicesExeMilanCommand() throws Exception
        {        com.milan.webservices.client.MilanServicesSoapBindingStub binding;
            try
            {
                binding = (com.milan.webservices.client.MilanServicesSoapBindingStub)new com.milan.webservices.client.MilanCommandServiceLocator()
                        .getmilanServices();
            }
            catch (javax.xml.rpc.ServiceException jre)
            {
                if(jre.getLinkedCause() != null)
                    jre.getLinkedCause().printStackTrace();
                throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: "
                        + jre);
            }
            assertNotNull("binding is null", binding);        //Time out after a minute
            binding.setTimeout(60000);        java.lang.String value = "webWebSercies ok";
            // Test operation
    出错点1:        value = binding.exeMilanCommand(new java.lang.String());
            // TBD - validate results
            System.out.println(value);
        }}
    在出错点1执行出现错误;
      

  8.   

    ,hava a look at it later
      

  9.   

    InvocationTargetException 多半是你
    对着别的类的  Class 对象, 用不同的类的实例调用 方法,
    如: String.Class.getMethod('trim()').invoke(integerObject) .  // integerObject 不是String 类型.所以请检查参数.