2 geduo 83 geduo_83 于 2013.12.29 15:31 提问

axis2 客户端调用报错,org.xml.sax.SAXException
- Exception:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
    at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    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:236)
    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.hxc.soap.HxcNewsServiceSoap12BindingStub.find(HxcNewsServiceSoap12BindingStub.java:254)
    at com.hxc.soap.Test.main(Test.java:11)
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
    at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    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:236)
    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.hxc.soap.HxcNewsServiceSoap12BindingStub.find(HxcNewsServiceSoap12BindingStub.java:254)
    at com.hxc.soap.Test.main(Test.java:11)

    {http://xml.apache.org/axis/}hostname:geduo_pc

org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
    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.hxc.soap.HxcNewsServiceSoap12BindingStub.find(HxcNewsServiceSoap12BindingStub.java:254)
    at com.hxc.soap.Test.main(Test.java:11)
Caused by: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
    at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    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:236)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    ... 4 more

服务端代码如下:

public class HxcNewsService implements IHxcNewsService {

    private IDao dao;   
    public void setDao(IDao dao) {
        this.dao = dao;
    }
    public HxcNews find(int id){
        System.out.println("find...");
        return (HxcNews) dao.find("com.ews.bean.HxcNews",id);
    }

    public void create(HxcNews baseBean){
        System.out.println("create...");
        dao.create(baseBean);
    }
    public String getStr(String name){
        return "nihao:"+name;
    }
}
public class Dao<T> extends HibernateDaoSupport implements IDao<T> {

    public T find(String str,int id) {

        try {
            T t = (T) getHibernateTemplate().get(str, id);
            return t;
        } catch (RuntimeException re) {         
            throw re;
        }

    }
}

客户端调用代码如下:

public class Test {
    public static void main(String[] args) {
        try {
            HxcNewsServicePortType hxcNewsServicePortType = new HxcNewsServiceLocator().getHxcNewsServiceHttpSoap12Endpoint();
            HxcNews news = hxcNewsServicePortType.find(1);
            System.out.println(news.getTitle());                    
        } catch (ServiceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}

wsdl:如下

<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions xmlns:ns="http://service.ews.com" targetNamespace="http://service.ews.com" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax21="http://dao.ews.com/xsd" xmlns:ax23="http://bean.ews.com/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><wsdl:documentation>HxcNewsService</wsdl:documentation>-<wsdl:types>-<xs:schema targetNamespace="http://service.ews.com" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns:ax22="http://dao.ews.com/xsd" xmlns:ax24="http://bean.ews.com/xsd"><xs:import namespace="http://dao.ews.com/xsd"/><xs:import namespace="http://bean.ews.com/xsd"/>-<xs:element name="setDao">+<xs:complexType>-</xs:element>-<xs:element name="getStr">-<xs:complexType>-<xs:sequence><xs:element name="name" type="xs:string" nillable="true" minOccurs="0"/></xs:sequence></xs:complexType></xs:element>-<xs:element name="getStrResponse">-<xs:complexType>-<xs:sequence><xs:element name="return" type="xs:string" nillable="true" minOccurs="0"/></xs:sequence></xs:complexType></xs:element>-<xs:element name="find">-<xs:complexType>-<xs:sequence><xs:element name="id" type="xs:int" minOccurs="0"/></xs:sequence></xs:complexType></xs:element>-<xs:element name="findResponse">-<xs:complexType>-<xs:sequence><xs:element name="return" type="ax24:HxcNews" nillable="true" minOccurs="0"/></xs:sequence></xs:complexType></xs:element>-<xs:element name="create">-<xs:complexType>-<xs:sequence><xs:element name="baseBean" type="ax24:HxcNews" nillable="true" minOccurs="0"/></xs:sequence></xs:complexType></xs:element></xs:schema>-<xs:schema targetNamespace="http://dao.ews.com/xsd" elementFormDefault="qualified" attributeFormDefault="qualified">-<xs:complexType name="IDao"><xs:sequence/></xs:complexType></xs:schema>-<xs:schema targetNamespace="http://bean.ews.com/xsd" elementFormDefault="qualified" attributeFormDefault="qualified">-<xs:complexType name="HxcNews">-<xs:sequence><xs:element name="addtime" type="xs:dateTime" nillable="true" minOccurs="0"/><xs:element name="content" type="xs:string" nillable="true" minOccurs="0"/><xs:element name="id" type="xs:int" nillable="true" minOccurs="0"/><xs:element name="title" type="xs:string" nillable="true" minOccurs="0"/></xs:sequence></xs:complexType></xs:schema></wsdl:types>-<wsdl:message name="createRequest"><wsdl:part name="parameters" element="ns:create"/></wsdl:message>-<wsdl:message name="getStrRequest"><wsdl:part name="parameters" element="ns:getStr"/></wsdl:message>-<wsdl:message name="getStrResponse"><wsdl:part name="parameters" element="ns:getStrResponse"/></wsdl:message>-<wsdl:message name="findRequest"><wsdl:part name="parameters" element="ns:find"/></wsdl:message>-<wsdl:message name="findResponse"><wsdl:part name="parameters" element="ns:findResponse"/></wsdl:message>-<wsdl:message name="setDaoRequest"><wsdl:part name="parameters" element="ns:setDao"/></wsdl:message>-<wsdl:portType name="HxcNewsServicePortType">-<wsdl:operation name="create"><wsdl:input wsaw:Action="urn:create" message="ns:createRequest"/></wsdl:operation>-<wsdl:operation name="getStr"><wsdl:input wsaw:Action="urn:getStr" message="ns:getStrRequest"/><wsdl:output wsaw:Action="urn:getStrResponse" message="ns:getStrResponse"/></wsdl:operation>-<wsdl:operation name="find"><wsdl:input wsaw:Action="urn:find" message="ns:findRequest"/><wsdl:output wsaw:Action="urn:findResponse" message="ns:findResponse"/></wsdl:operation>-<wsdl:operation name="setDao"><wsdl:input wsaw:Action="urn:setDao" message="ns:setDaoRequest"/></wsdl:operation></wsdl:portType>-<wsdl:binding name="HxcNewsServiceSoap11Binding" type="ns:HxcNewsServicePortType"><soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>-<wsdl:operation name="create"><soap:operation style="document" soapAction="urn:create"/>-<wsdl:input><soap:body use="literal"/></wsdl:input></wsdl:operation>-<wsdl:operation name="getStr"><soap:operation style="document" soapAction="urn:getStr"/>-<wsdl:input><soap:body use="literal"/></wsdl:input>-<wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation>-<wsdl:operation name="find"><soap:operation style="document" soapAction="urn:find"/>-<wsdl:input><soap:body use="literal"/></wsdl:input>-<wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation>-<wsdl:operation name="setDao"><soap:operation style="document" soapAction="urn:setDao"/>-<wsdl:input><soap:body use="literal"/></wsdl:input></wsdl:operation></wsdl:binding>-<wsdl:binding name="HxcNewsServiceSoap12Binding" type="ns:HxcNewsServicePortType"><soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>-<wsdl:operation name="create"><soap12:operation style="document" soapAction="urn:create"/>-<wsdl:input><soap12:body use="literal"/></wsdl:input></wsdl:operation>-<wsdl:operation name="getStr"><soap12:operation style="document" soapAction="urn:getStr"/>-<wsdl:input><soap12:body use="literal"/></wsdl:input>-<wsdl:output><soap12:body use="literal"/></wsdl:output></wsdl:operation>-<wsdl:operation name="find"><soap12:operation style="document" soapAction="urn:find"/>-<wsdl:input><soap12:body use="literal"/></wsdl:input>-<wsdl:output><soap12:body use="literal"/></wsdl:output></wsdl:operation>-<wsdl:operation name="setDao"><soap12:operation style="document" soapAction="urn:setDao"/>-<wsdl:input><soap12:body use="literal"/></wsdl:input></wsdl:operation></wsdl:binding>-<wsdl:binding name="HxcNewsServiceHttpBinding" type="ns:HxcNewsServicePortType"><http:binding verb="POST"/>-<wsdl:operation name="create"><http:operation location="HxcNewsService/create"/>-<wsdl:input><mime:content type="text/xml" part="create"/></wsdl:input></wsdl:operation>-<wsdl:operation name="getStr"><http:operation location="HxcNewsService/getStr"/>-<wsdl:input><mime:content type="text/xml" part="getStr"/></wsdl:input>-<wsdl:output><mime:content type="text/xml" part="getStr"/></wsdl:output></wsdl:operation>-<wsdl:operation name="find"><http:operation location="HxcNewsService/find"/>-<wsdl:input><mime:content type="text/xml" part="find"/></wsdl:input>-<wsdl:output><mime:content type="text/xml" part="find"/></wsdl:output></wsdl:operation>-<wsdl:operation name="setDao"><http:operation location="HxcNewsService/setDao"/>-<wsdl:input><mime:content type="text/xml" part="setDao"/></wsdl:input></wsdl:operation></wsdl:binding>-<wsdl:service name="HxcNewsService">-<wsdl:port name="HxcNewsServiceHttpSoap11Endpoint" binding="ns:HxcNewsServiceSoap11Binding"><soap:address location="http://127.0.0.1:8080/s2sh/services/HxcNewsService.HxcNewsServiceHttpSoap11Endpoint/"/></wsdl:port>-<wsdl:port name="HxcNewsServiceHttpSoap12Endpoint" binding="ns:HxcNewsServiceSoap12Binding"><soap12:address location="http://127.0.0.1:8080/s2sh/services/HxcNewsService.HxcNewsServiceHttpSoap12Endpoint/"/></wsdl:port>-<wsdl:port name="HxcNewsServiceHttpEndpoint" binding="ns:HxcNewsServiceHttpBinding"><http:address location="http://127.0.0.1:8080/s2sh/services/HxcNewsService.HxcNewsServiceHttpEndpoint/"/></wsdl:port></wsdl:service></wsdl:definitions>
Csdn user default icon
上传中...
上传图片
插入图片