java-axis2 客户端调用报错,org.xml.sax.SAXException

问题描述

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>
时间: 2024-08-04 05:48:06

java-axis2 客户端调用报错,org.xml.sax.SAXException的相关文章

java-cxf webservice客户端调用报错.高手请进.

问题描述 cxf webservice客户端调用报错.高手请进. <!-- WebServices设置 --> <servlet> <servlet-name>CXFServices</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> <load-on-startup>1</load-on-

cxf restful 参数中有map,调用报错,如何处理(不能二次封装map),请大神帮解一下

问题描述 cxf restful 参数中有map,调用报错,如何处理(不能二次封装map),请大神帮解一下 service代码: @GET @Path("/map") @Produces({"application/json","application/xml"}) public String mapTest(@QueryParam("map")Map map){ return "a"; } 调用代码: M

phprpc远程调用报错,不知道什么原因

问题描述 phprpc远程调用报错,不知道什么原因 我在学习phprpc远程调用,按照网上的教程,发现报错:Incorrect response id (request id: 1, response id: ) n:好纠结啊,求教.贴出代码如下: 服务端,member.php <?php require_once 'jsonRPCServer.php'; /** User: Administrator Date: 2015/12/28 Time: 11:06 */ class member {

java8 java.time引用-java.time.*为什么引用报错?

问题描述 java.time.*为什么引用报错? 我用的最新的JAVA8 可是在使用import java.time. 还是会报错 有谁知道这是为什么么? 解决方案 问题得到解决,是在myeclipse中,没用把JDK8使用进去,所以系统虽然配置了JDK8,可是在我的myeclipse2014中,创建项目时还用的JDK7,所以java.time.的包没有能够被引用,配置使用JDK8后,重新创建项目,可以正常使用,不会再报错了! 解决方案二: 如何解决Eclipse中Java工程间循环引用而报错的

webservice axis发布service时候总报错noclassdeffoundError:org/xml/sax/saxexception

问题描述 我说下我的步骤按照教程配置的 配置好axis了 即使发布也跑通了http://localhost:8080/axis/HelloAXIS.jws现在配置的是定制发布写了2个JAVA类,用Myeclipse编译成.class文件了,放入D:Tomcat 6.0webappsaxisWEB-INFclasses里了再就是编写deploy.wsdd了 <!-- Use this file to deploy some handlers/chains and services --><

web.xml引用外部xml文件。以及org.xml.sax.SAXException

很多时候因为各种各样的原因,需要在各种xml文件来引用外部的xml文件. 我遇到了两种,一种是普通配置的xml文件引用外部xml文件. 可以用 <import resource="classpath:tuloginContext.xml" /> 这是相对路径,当然,这句代码的位置需要注意.这个在beans下面,与bean平级,如果写错了,会不执行,就会导入出错,或者就是不执行也不报错. <beans> <import resource="clas

axis1.4 调用报错:faultString: java.lang.reflect.InvocationTargetException

问题描述 本来在本地我开两个项目访问是没问题的,然后我把服务端发布在客户的服务器上,在本地写测试代码调用接口时就报错了,望大神指点迷津,我弄了一天了,都快疯了..错误如下:AxisFaultfaultCode:{http://schemas.xmlsoap.org/soap/envelope/}Server.userExceptionfaultSubcode:faultString:java.lang.reflect.InvocationTargetExceptionfaultActor:fau

【技术贴】webservice cxf2 客户端动态调用报错No operation was found with the name

  No operation was found with the name xxx 出错原因是因为发布服务的接口所在包路径和此接口实现类包路径不一致,比如你的服务接口可能放在了包com.x.interFace下,但是你的实现类却在com.x.interFace.impl包下,此时,发布的服务被客户端动态调用(JaxWsDynamicClientFactory)的时候,就会报错: org.apache.cxf.common.i18n.UncheckedException: No operatio

axis2客户端执行时报错,请帮忙解决下,多谢了!

问题描述 新学webservice,实在不知道啥意思,客户端代码如下:importorg.apache.axis2.AxisFault;importorg.apache.axis2.rpc.client.RPCServiceClient;importorg.apache.axis2.addressing.EndpointReference;importorg.apache.axis2.client.Options;importjavax.xml.namespace.QName;publiccla