错误[org.apache.axis.encoding.ser.BeanSerializer](默认任务2)异常:java.lang.NullPointerException

时间:2018-10-14 04:32:58

标签: soap

我已经创建了一个SOAP服务,该WS端点正在接受String并返回枚举值。返回枚举值时,它抛出错误以下。 我不确定为什么即使我从WS服务方法返回枚举值,它也会引发Nullpointer异常。

09:44:06,951 INFO  [stdout] (default task-2) enum opoeration method called:hii

09:44:06,962 INFO  [stdout] (default task-2) enum value:PERMANENT

09:44:07,413 ERROR [org.apache.axis.encoding.ser.BeanSerializer] (default task-2) Exception:: java.lang.NullPointerException
    at org.apache.axis.encoding.TypeMappingImpl.isArray(TypeMappingImpl.java:139) [axis.jar:]
    at org.apache.axis.encoding.TypeMappingImpl.getTypeQName(TypeMappingImpl.java:657) [axis.jar:]
    at org.apache.axis.encoding.TypeMappingDelegate.getTypeQName(TypeMappingDelegate.java:151) [axis.jar:]
    at org.apache.axis.encoding.SerializationContext.getQNameForClass(SerializationContext.java:602) [axis.jar:]
    at org.apache.axis.encoding.ser.ArraySerializer.serialize(ArraySerializer.java:208) [axis.jar:]
    at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1504) [axis.jar:]
    at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980) [axis.jar:]
    at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:734) [axis.jar:]
    at org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:230) [axis.jar:]
    at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1504) [axis.jar:]
    at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980) [axis.jar:]
    at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:734) [axis.jar:]
    at org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:230) [axis.jar:]
    at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1504) [axis.jar:]
    at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980) [axis.jar:]
    at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:801) [axis.jar:]
    at org.apache.axis.message.RPCParam.serialize(RPCParam.java:208) [axis.jar:]
    at org.apache.axis.message.RPCElement.outputImpl(RPCElement.java:433) [axis.jar:]
    at org.apache.axis.message.MessageElement.output(MessageElement.java:1208) [axis.jar:]
    at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:139) [axis.jar:]
    at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:478) [axis.jar:]
    at org.apache.axis.message.MessageElement.output(MessageElement.java:1208) [axis.jar:]
    at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:315) [axis.jar:]
    at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:269) [axis.jar:]
    at org.apache.axis.SOAPPart.saveChanges(SOAPPart.java:530) [axis.jar:]
    at org.apache.axis.attachments.AttachmentsImpl.getAttachmentCount(AttachmentsImpl.java:554) [axis.jar:]
    at org.apache.axis.Message.getContentType(Message.java:486) [axis.jar:]
    at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:775) [axis.jar:]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
    at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327) [axis.jar:]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:248) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:77) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:167) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:761) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_161]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_161]
    at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_161]

这是服务端点代码:

@WebService
@SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL)
public class HelloServiceImpl {
    @WebMethod 
    public EmployeeType enumReturn(@WebParam(name="arg0")String arg0){
        System.out.println("enum opoeration method called:"+arg0);
        System.out.println("enum value:"+EmployeeType.PERMANENT);
        return EmployeeType.PERMANENT;
    }
}

枚举文件:

@XmlRootElement(name = "employeeType", namespace = "http://soapresource.learn.com/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlEnum ( value = String.class )
//@XmlType(name = "employeeType", namespace = "http://soapresource.learn.com/")
public enum EmployeeType implements Serializable{
    @XmlEnumValue(value = "TEMPORARY") TEMPORARY("TEMPORARY"),
    @XmlEnumValue(value = "PERMANENT") PERMANENT("PERMANENT");
    @XmlElement( name = "employeeType", namespace = "" )
    private String empType;
    EmployeeType(String str){
        empType = str;

    }
    public String getEmpType(){
        System.out.println("enum file get called");
        return empType;
    }
}

WSDL文件:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://soapresource.learn.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://soapresource.learn.com" xmlns:intf="http://soapresource.learn.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://soapresource.learn.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <element name="enumReturn">
    <complexType>
     <sequence>
      <element name="arg0" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>
   <element name="enumReturnResponse">
    <complexType>
     <sequence>
      <element name="enumReturnReturn" type="xsd:anyType"/>
     </sequence>
    </complexType>
   </element>
  </schema>
 </wsdl:types>

   <wsdl:message name="enumReturnRequest">

      <wsdl:part element="impl:enumReturn" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:message name="enumReturnResponse">

      <wsdl:part element="impl:enumReturnResponse" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:portType name="HelloServiceImpl">

      <wsdl:operation name="enumReturn">

         <wsdl:input message="impl:enumReturnRequest" name="enumReturnRequest">

       </wsdl:input>

         <wsdl:output message="impl:enumReturnResponse" name="enumReturnResponse">

       </wsdl:output>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="HelloServiceImplSoapBinding" type="impl:HelloServiceImpl">

      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="enumReturn">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="enumReturnRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="enumReturnResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="HelloServiceImplService">

      <wsdl:port binding="impl:HelloServiceImplSoapBinding" name="HelloServiceImpl">

         <wsdlsoap:address location="http://localhost:8080/soapapi/services/HelloServiceImpl"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

最后一个是wsdd文件:

<ns1:deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java" xmlns:ns1="http://xml.apache.org/axis/wsdd/">
 <ns1:globalConfiguration>
  <ns1:parameter name="sendMultiRefs" value="true"/>
  <ns1:parameter name="disablePrettyXML" value="true"/>
  <ns1:parameter name="adminPassword" value="admin"/>
  <ns1:parameter name="attachments.Directory" value="C:\Users\raviro\Desktop\Doc\wildfly-8.2.1.Final\standalone\deployments\soapapi.war\WEB-INF\attachments"/>
  <ns1:parameter name="dotNetSoapEncFix" value="true"/>
  <ns1:parameter name="enableNamespacePrefixOptimization" value="false"/>
  <ns1:parameter name="sendXMLDeclaration" value="true"/>
  <ns1:parameter name="sendXsiTypes" value="true"/>
  <ns1:parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl"/>
  <ns1:requestFlow>
   <ns1:handler type="java:org.apache.axis.handlers.JWSHandler">
    <ns1:parameter name="scope" value="session"/>
   </ns1:handler>
   <ns1:handler type="java:org.apache.axis.handlers.JWSHandler">
    <ns1:parameter name="scope" value="request"/>
    <ns1:parameter name="extension" value=".jwr"/>
   </ns1:handler>
  </ns1:requestFlow>
 </ns1:globalConfiguration>
 <ns1:handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
 <ns1:handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
 <ns1:handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
 <ns1:service name="AdminService" provider="java:MSG">
  <ns1:parameter name="allowedMethods" value="AdminService"/>
  <ns1:parameter name="enableRemoteAdmin" value="false"/>
  <ns1:parameter name="className" value="org.apache.axis.utils.Admin"/>
  <ns1:namespace>http://xml.apache.org/axis/wsdd/</ns1:namespace>
 </ns1:service>
 <ns1:service name="Version" provider="java:RPC">
  <ns1:parameter name="allowedMethods" value="getVersion"/>
  <ns1:parameter name="className" value="org.apache.axis.Version"/>
 </ns1:service>
 <ns1:service name="HelloServiceImpl" provider="java:RPC" style="wrapped" use="literal">
  <ns1:operation name="enumReturn" qname="ns7:enumReturn" returnQName="ns7:enumReturnReturn" returnType="xsd:anyType" soapAction="" xmlns:ns7="http://soapresource.learn.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <ns1:parameter qname="ns7:arg0" type="xsd:string"/>
  </ns1:operation>
  <ns1:parameter name="allowedMethods" value="enumReturn"/>
  <ns1:parameter name="typeMappingVersion" value="1.2"/>
  <ns1:parameter name="wsdlPortType" value="HelloServiceImpl"/>
  <ns1:parameter name="className" value="com.learn.soapresource.HelloServiceImpl"/>
  <ns1:parameter name="wsdlServicePort" value="HelloServiceImpl"/>
  <ns1:parameter name="schemaQualified" value="http://soapresource.learn.com"/>
  <ns1:parameter name="wsdlTargetNamespace" value="http://soapresource.learn.com"/>
  <ns1:parameter name="wsdlServiceElement" value="HelloServiceImplService"/>
  <ns1:typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="" qname="ns9:EmployeeType" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" type="java:com.learn.soapresource.EmployeeType" xmlns:ns9="http://soapresource.learn.com"/>
  <ns1:typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="" qname="ns10:Class" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" type="java:java.lang.Class" xmlns:ns10="http://soapresource.learn.com"/>
 </ns1:service>
 <ns1:transport name="http">
  <ns1:requestFlow>
   <ns1:handler type="URLMapper"/>
   <ns1:handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
  </ns1:requestFlow>
  <ns1:parameter name="qs:list" value="org.apache.axis.transport.http.QSListHandler"/>
  <ns1:parameter name="qs:wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
  <ns1:parameter name="qs.list" value="org.apache.axis.transport.http.QSListHandler"/>
  <ns1:parameter name="qs.method" value="org.apache.axis.transport.http.QSMethodHandler"/>
  <ns1:parameter name="qs:method" value="org.apache.axis.transport.http.QSMethodHandler"/>
  <ns1:parameter name="qs.wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
 </ns1:transport>
 <ns1:transport name="local">
  <ns1:responseFlow>
   <ns1:handler type="LocalResponder"/>
  </ns1:responseFlow>
 </ns1:transport>
</ns1:deployment>

0 个答案:

没有答案