spring和axis集成问题,could not find deserializer
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Deserializing parameter 'ValidateUsersResult': could not find deserializer for type {http://tempuri.org/}RegUserItem
faultActor:
faultNode:
faultDetail:
org.xml.sax.SAXException: Deserializing parameter 'ValidateUsersResult': could not find deserializer for type {http://tempuri.org/}RegUserItem
spring的版本是2.0,基本上是安装spring2.0的手册一步步配置的,查了很多资料和论坛发现有不少人遇到这个问题,但就是没有解决方法。。
感觉是导入的包或者是命名空间的问题,wsdl自己又不太熟。。
代码如下:
spring配置文件:
1. <bean id="ticketServiceBridge" class="com.fortinet.service.openAPI.ticket.model.econnect.AxisPortProxyFactoryBean">
2. <property name="serviceInterface">
3. <value>com.fortinet.service.openAPI.ticket.model.econnect.TicketServiceBridgeSoap</value>
4. </property>
5. <property name="wsdlDocumentUrl">
6. <value>http://172.22.13.2/ForticareWebService/TicketService.asmx?WSDL</value>
7. </property>
8. <property name="namespaceUri">
9. <value>http://tempuri.org/</value>
10. </property>
11. <property name="serviceName">
12. <value>TicketService</value>
13. </property>
14. <property name="portName">
15. <value>TicketServiceSoap</value>
16. </property>
17. </bean>
18.
19. <bean id="ticketServiceClient" class="com.fortinet.service.openAPI.ticket.model.econnect.TicketServiceClientImpl">
20. <property name="ticketServiceBridge">
21. <ref bean="ticketServiceBridge"/>
22. </property>
23. </bean>
实现自定义类注册功能的factorybean
1. package com.fortinet.service.openAPI.ticket.model.econnect;
2.
3. import javax.xml.namespace.QName;
4. import javax.xml.rpc.Service;
5. import javax.xml.rpc.encoding.TypeMapping;
6. import javax.xml.rpc.encoding.TypeMappingRegistry;
7.
8. import org.apache.axis.encoding.ser.BeanDeserializerFactory;
9. import org.apache.axis.encoding.ser.BeanSerializerFactory;
10. import org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean;
11.
12. import com.fortinet.service.openAPI.ticket.model.RegUserItem;
13.
14. public class AxisPortProxyFactoryBean extends JaxRpcPortProxyFactoryBean{
15. protected void postProcessJaxRpcService(Service service) {
16. TypeMappingRegistry registry = service.getTypeMappingRegistry();
17. TypeMapping mapping = registry.createTypeMapping();
18. registerBeanMapping(mapping, RegUserItem.class, "RegUserItem");
19. registry.register("http://schemas.xmlsoap.org/soap/encoding/", mapping);
20. }
21.
22. protected void registerBeanMapping(TypeMapping mapping, Class type, String name) {
23. QName qName = new QName("http://tempuri.org/", name);
24. mapping.register(type, qName,
25. new BeanSerializerFactory(type, qName),
26. new BeanDeserializerFactory(type, qName));
27. }
28.
29. }
供使用的wsdl文件,webservice是用.net由另外一个人实现的:
# <?xml version="1.0" encoding="utf-8" ?>
# <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
# xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
# xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
# xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
# xmlns:tns="http://tempuri.org/"
# xmlns:s="http://www.w3.org/2001/XMLSchema"
# xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
# xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
# targetNamespace="http://tempuri.org/"
# xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
#
# <wsdl:types>
#
# <s:schema elementFormDefault="qualified"
# targetNamespace="http://tempuri.org/">
#
# <s:element name="ValidateUsers">
#
# <s:complexType>
#
# <s:sequence>
# <s:element minOccurs="0" maxOccurs="1"
# name="UserRegID" type="s:string" />
# <s:element minOccurs="0" maxOccurs="1"
# name="UserRegPwd" type="s:string" />
# </s:sequence>
# </s:complexType>
# </s:element>
#
# <s:element name="ValidateUsersResponse">
#
# <s:complexType>
#
# <s:sequence>
# <s:element minOccurs="0" maxOccurs="1"
# name="ValidateUsersResult" type="tns:RegUserItem" />
# </s:sequence>
# </s:complexType>
# </s:element>
# <s:complexType name="RegUserItem">
#
# <s:sequence>
# <s:element minOccurs="0" maxOccurs="1" name="userId"
# type="s:string" />
# <s:element minOccurs="0" maxOccurs="1"
# name="userType" type="s:string" />
# </s:sequence>
# </s:complexType>
# </s:schema>
# </wsdl:types>
#
# <wsdl:message name="ValidateUsersSoapIn">
# <wsdl:part name="parameters" element="tns:ValidateUsers" />
# </wsdl:message>
#
# <wsdl:message name="ValidateUsersSoapOut">
# <wsdl:part name="parameters"
# element="tns:ValidateUsersResponse" />
# </wsdl:message>
#
# <wsdl:portType name="TicketServiceSoap">
#
# <wsdl:operation name="ValidateUsers">
# <wsdl:input message="tns:ValidateUsersSoapIn" />
# <wsdl:output message="tns:ValidateUsersSoapOut" />
# </wsdl:operation>
# ...
# </wsdl:portType>
#
# <wsdl:binding name="TicketServiceSoap"
# type="tns:TicketServiceSoap">
# <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
#
# <wsdl:operation name="ValidateUsers">
# <soap:operation
# soapAction="http://tempuri.org/ValidateUsers" style="document" />
#
# <wsdl:input>
# <soap:body use="literal" />
# </wsdl:input>
#
# <wsdl:output>
# <soap:body use="literal" />
# </wsdl:output>
# </wsdl:operation>
# </wsdl:binding>
#
# <wsdl:service name="TicketService">
#
# <wsdl:port name="TicketServiceSoap"
# binding="tns:TicketServiceSoap">
# <soap:address
# location="http://172.22.13.2/ForticareWebService/TicketService.asmx" />
# </wsdl:port>
#
# <wsdl:port name="TicketServiceSoap12"
# binding="tns:TicketServiceSoap12">
# <soap12:address
# location="http://172.22.13.2/ForticareWebService/TicketService.asmx" />
# </wsdl:port>
# </wsdl:service>
# </wsdl:definitions>