找不到类型的反序列化器:错误 [英] could not find deserializer for type : Error

查看:169
本文介绍了找不到类型的反序列化器:错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从我的java程序进行SOAP调用,为此我使用了apache轴。
我的程序如下:

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.apache.axis.client.Service;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
public class Project {
   public static void main(String [] args) {

   try {

       String endpoint ="http://RequestUrl";
       Service  service = new Service();
       Call call = (Call) service.createCall();
       call.setTargetEndpointAddress( new java.net.URL(endpoint) );
       call.setOperationName(new QName(endpoint, "getFrsFileData"));
       String value = (String) call.invoke(new Object[] { "24BB7","frs1001" } );
       System.out.println(value);
       }

    catch (Exception e) {
       System.err.println(e.toString());
       }

    }
   }

这是关于执行给出如下错误

This on execution gives an error as follows



  • 异常:
    org.xml.sax.SAXException:反序列化参数'getFrsFileDataReturn':org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:277)
    at org.apache找不到类型{http:// Url} FrsFileSoapDO
    的反序列化器.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:345)
    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)org.apache.axis.clien的
    t.Call.invoke(Call.java:1812)Project.main上的
    (Project.java:33)
    org.xml.sax.SAXException:反序列化参数'getFrsFileDataReturn':找不到反序列化器输入{http:// Url} FrsFileSoapDO

尝试使用SOAPUI进行相同的调用,但确实如此不帮我调试一下。

Tried the same call using SOAPUI , but it did not help me debug this .

请帮我调试一下这段java代码,

Please help me out in debugging this java code,

谢谢你

推荐答案

我得到了朋友的帮助,得到了答案。
问题是soap调用会给出一个肥皂响应,它是一个类型为FrsFileSoapDO的bean。由于我没有在代码中提供任何代码来说明我的程序将如何理解收到的bean,这给了我一个错误,说无法找到类型的解串器{http:// Url} FrsFileSoapDO
现在清除问题的步骤是

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)创建一个QName来说明FrsFileSoapDO所指的命名空间是什么。

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

2)创建Bean序列化程序(知道如何序列化bean),

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

3)创建Bean反序列化程序(知道如何反序列化bean),

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

4)映射说QName q映射到类FrsFileSoapDO.class(之前确保你有FrsFileSoapDO) .class和你一起导入它)

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 )

现在让我们在程序中实现它,(我在这里只重复try块)

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.

函数Call,BeanSerializerFactory,BeanDeserializerFactory的文档可在 BeanSerializerFactory BeanDeserializerFactory

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

这篇关于找不到类型的反序列化器:错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆