could not find deserializer for type : Error

前端 未结 2 1244
萌比男神i
萌比男神i 2020-12-21 07:11

I have to make a SOAP call from my java program ,for which I used apache axis. My program is as follows :

import org.apache.axis.client.Call;
import org.apa         


        
2条回答
  •  盖世英雄少女心
    2020-12-21 07:37

    I got help from my friend and was able to arrive at the answer . The problem is that the soap call , gives a soap response which comes as a bean of type "FrsFileSoapDO" . As I have not given anything in code of how my program will understand the received bean , that gave me an error saying "could not find deserializer for type {http://Url}FrsFileSoapDO" . Now the step's to clear the problem is

    1) create a "QName" to say what is the namespace that "FrsFileSoapDO" refers to .

    2) create Bean serializer (that knows how to serialize the bean),

    3) create a Bean deserializer (that knows how to deserialize the bean) ,

    4) Do the mapping saying that the QName q maps to the class FrsFileSoapDO.class (before that make sure that you have the FrsFileSoapDO.class with you and you have imported it )

    Now lets implement this in the program , (I am repeating only the try block here)

    try {
    
       String endpoint ="http://RequestUrl";
       Service  service = new Service();
       Call call = (Call) service.createCall();
       call.setTargetEndpointAddress( new java.net.URL(endpoint) );
    
       QName q = new QName ("http://Url", "FrsFileSoapDO"); // step 1
       BeanSerializerFactory bsf =   new BeanSerializerFactory(FrsFileSoapDO.class,q);   // step 2
       BeanDeserializerFactory bdf = new BeanDeserializerFactory(FrsFileSoapDO.class,q);  // step 3
       call.registerTypeMapping(FrsFileSoapDO.class,q, bsf, bdf); //step 4
    
       call.setOperationName(new QName(endpoint, "getFrsFileData"));
       FrsFileSoapDO s = (FrsFileSoapDO) call.invoke(new Object[] { "24BB7","frs1001" } );  
       System.out.println(s.getFilename());  
       }
    

    This works giving me the expected output.

    The document for the functions Call,BeanSerializerFactory,BeanDeserializerFactory are available at BeanSerializerFactory and BeanDeserializerFactory

提交回复
热议问题