| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2954 人关注过本帖
标题:AXIS 出错..郁闷很久..期待高手指点..
取消只看楼主 加入收藏
being
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-3-29
收藏
 问题点数:0 回复次数:1 
AXIS 出错..郁闷很久..期待高手指点..
Server.java

package com.outsource;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
public class Server {
    public Document doCreate()
    {
        List list = new ArrayList();
        A a = new A();
        a.setName("ABC");
        a.setPwd("123456");
        a.setSex("男");
        list.add(a);
        a = new A();
        a.setName("being");
        a.setPwd("123456");
        list.add(a);
        a = new A();
        a.setName("ZBY");
        a.setPwd("123456");
        a.setSex("BOY");
        list.add(a);
        Element Root = new Element("USERS");
        Document Doc = new Document(Root);
        Element Attribute = null;
        Element Center = null;
        for(int i=0;i<list.size();i++)
        {
            Center = new Element("USERS".substring(0, "USERS".length()-1));
            Root.addContent(Center);
            Field[] fd = list.get(i).getClass().getDeclaredFields();
            for(int j=0;j<fd.length;j++)
            {
                String fdname = fd[j].getName();
                StringBuffer buf=new StringBuffer();
                buf.append("get");
                buf.append(fdname.substring(0,1).toUpperCase());
                buf.append(fdname.substring(1));
                try{
                    Method method = list.get(i).getClass().getDeclaredMethod(buf.toString());
                    fdname = fdname.toLowerCase();
                    String ss = (method.invoke(list.get(i))==null?" ":method.invoke(list.get(i)).toString());
                    Attribute = new Element(fdname);
                    Attribute.setText(ss);
                    Center.addContent(Attribute);
                }catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
        }
        return Doc;
    }
    public String test(){
        
        return "BEING.zhou";
    }
}

------------------------------------------------
server-config.wsdd
------------------------------------------------

<service name="Server" provider="java:RPC">
       <parameter name="className" value="com.outsource.Server"/>
       <parameter name="allowedMethods" value="*"/>

<!-- 具体某个方法说明 -->
       <typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"   
       encodingStyle="http://schemas.
       qname="ns:Document"
       serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
       type="java:org.jdom.Document"
       xmlns:ns="Server"/>
        
       <typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"   
       encodingStyle="http://schemas.
       qname="ns:DescendantIterator"
       serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
       type="java:org.jdom.DescendantIterator"      
       xmlns:ns="Server"/>
        
       <typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"   
       encodingStyle="http://schemas.
       qname="ns:DescendantIterator"
       serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"        
       type="java:org.jdom.DescendantIterator"      
       xmlns:ns="Server"/>        
        
        
       <typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
       encodingStyle="http://schemas.
       qname="ns:Element"
       serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
       type="java:org.jdom.Element"
       xmlns:ns="Server"/>
        
       <typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
       encodingStyle="http://schemas.
       qname="ns:Namespace"
       serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
       type="java:org.jdom.Namespace" xmlns:ns="Server"/>
</service>
------------------------------
web.xml
-----------------------------
<web-app>
  <display-name>Apache-Axis</display-name>
   
    <listener>
        <listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
    </listener>
   
  <servlet>
    <servlet-name>AxisServlet</servlet-name>
    <display-name>Apache-Axis Servlet</display-name>
    <servlet-class>
        org.apache.axis.transport.http.AxisServlet
    </servlet-class>
  </servlet>

  <servlet>
    <servlet-name>AdminServlet</servlet-name>
    <display-name>Axis Admin Servlet</display-name>
    <servlet-class>
        org.apache.axis.transport.http.AdminServlet
    </servlet-class>
    <load-on-startup>100</load-on-startup>
  </servlet>

  <servlet>
    <servlet-name>SOAPMonitorService</servlet-name>
    <display-name>SOAPMonitorService</display-name>
    <servlet-class>
        org.apache.axis.monitor.SOAPMonitorService
    </servlet-class>
    <init-param>
      <param-name>SOAPMonitorPort</param-name>
      <param-value>5001</param-value>
    </init-param>
    <load-on-startup>100</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/servlet/AxisServlet</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>*.jws</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>SOAPMonitorService</servlet-name>
    <url-pattern>/SOAPMonitor</url-pattern>
  </servlet-mapping>

 <!-- uncomment this if you want the admin servlet -->
 <!--
  <servlet-mapping>
    <servlet-name>AdminServlet</servlet-name>
    <url-pattern>/servlet/AdminServlet</url-pattern>
  </servlet-mapping>
 -->

    <session-config>
        <!-- Default to 5 minute session timeouts -->
        <session-timeout>5</session-timeout>
    </session-config>

    <!-- currently the W3C havent settled on a media type for WSDL;
    [url]http://www.[/url]
    for now we go with the basic 'it's XML' response -->
  <mime-mapping>
    <extension>wsdl</extension>
     <mime-type>text/xml</mime-type>
  </mime-mapping>
  

  <mime-mapping>
    <extension>xsd</extension>
    <mime-type>text/xml</mime-type>
  </mime-mapping>

  <welcome-file-list id="WelcomeFileList">
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.jws</welcome-file>
  </welcome-file-list>

</web-app>

---------------------

调用
Client.java
---------------------
package com.outsource;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.jdom.Document;
import org.jdom.Element;
import com.
public class Client {

    public static void main(String args[])
    {
        try{
        String endpoint = "http://localhost:8080/AXIS/services/Server?wsdl";//指明服务所在位置
           Service  service = new Service();  //创建一个Service实例,注意是必须的!
           Call     call    = (Call) service.createCall();//创建Call实例,也是必须的!
         call.setTargetEndpointAddress( new (endpoint) );//为Call设置服务的位置
         QName qn = new QName("Server","Document");
         call.registerTypeMapping(Document.class, qn,    new BeanSerializerFactory(Document.class, qn),    new BeanDeserializerFactory(Document.class, qn));
         qn = new QName("Server","DescendantIterator");
         call.registerTypeMapping(DescendantIterator.class, qn,    new BeanSerializerFactory(DescendantIterator.class, qn),    new BeanDeserializerFactory(DescendantIterator.class, qn));
         qn = new QName("Server","Element");
         call.registerTypeMapping(Element.class, qn,    new BeanSerializerFactory(Element.class, qn),    new BeanDeserializerFactory(Element.class, qn));
//         qn = new QName("Server","DescendantIterator");
//         call.registerTypeMapping(Document.class, qn,    new BeanSerializerFactory(DescendantIterator.class, qn),    new BeanDeserializerFactory(DescendantIterator.class, qn));
            call.setOperationName("doCreate");//注意方法名与HelloWorld.java中一样!!
             Document res = (Document) call.invoke( new Object[] {} );//返回String,没有传入参数
//             String res = (String) call.invoke( new Object[] {} );//返回String,没有传入参数
            System.out.println( res );
        }catch(Exception e){e.printStackTrace();}
    }
}
-----------------------------

----------------------------出现问题
- Exception:
org.xml.sax.SAXException: No object was found for class type class java.lang.String
    at org.apache.axis.encoding.ConstructorTarget.set(ConstructorTarget.java:97)
    at org.apache.axis.encoding.DeserializerImpl.valueComplete(DeserializerImpl.java:249)
    at org.apache.axis.encoding.ser.ArrayDeserializer.valueComplete(ArrayDeserializer.java:583)
    at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:509)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:171)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeserializer.java:154)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:345)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.outsource.Client.main(Client.java:32)
AxisFault
 faultCode: {[url]http://schemas.[/url]}Server.userException
 faultSubcode:
 faultString: org.xml.sax.SAXException: No object was found for class type class java.lang.String
 faultActor:
 faultNode:
 faultDetail:
    {[url]http://xml.[/url]}stackTrace:org.xml.sax.SAXException: No object was found for class type class java.lang.String
    at org.apache.axis.encoding.ConstructorTarget.set(ConstructorTarget.java:97)
    at org.apache.axis.encoding.DeserializerImpl.valueComplete(DeserializerImpl.java:249)
    at org.apache.axis.encoding.ser.ArrayDeserializer.valueComplete(ArrayDeserializer.java:583)
    at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:509)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:171)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeserializer.java:154)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:345)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.outsource.Client.main(Client.java:32)

    {[url]http://xml.[/url]}hostname:287d5450a85841f

org.xml.sax.SAXException: No object was found for class type class java.lang.String
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
    at org.apache.axis.client.Call.invoke(Call.java:2470)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.outsource.Client.main(Client.java:32)
Caused by: org.xml.sax.SAXException: No object was found for class type class java.lang.String
    at org.apache.axis.encoding.ConstructorTarget.set(ConstructorTarget.java:97)
    at org.apache.axis.encoding.DeserializerImpl.valueComplete(DeserializerImpl.java:249)
    at org.apache.axis.encoding.ser.ArrayDeserializer.valueComplete(ArrayDeserializer.java:583)
    at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:509)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:171)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeserializer.java:154)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:345)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    ... 3 more
-----------------------------------------

-----------------------------------------
期待解决..
MSN: [email]zby0308@[/email]
谢谢...
搜索更多相关主题的帖子: AXIS import quot java 
2007-12-19 10:08
being
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-3-29
收藏
得分:0 
黄袖标同志!
谢谢....
我的Email:[email]zby0209@[/email]
感激不尽..............

小弟新来的!请多指教!
2007-12-19 11:56
快速回复:AXIS 出错..郁闷很久..期待高手指点..
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036366 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved