• axis2框架用wsdl文件生成的服务端MessageReceiveInOut文件注意事项


           在用axis2生成服务端文件和客户端文件,当客户端文件调用服务端文件时,都是通过wsdl文件生成的

    配置文件进行相互的调用。

            在一开始做开发测试的时候,通过soapUI进行调用接口的时候,可以调用成功,但这只是服务端调用,

    并没有通过客户端进行调用。当服务端开发接收后,开发客户端,由客户端调用服务端文件时,一直没有调通,

    后来经高人指点,原因在于生成的服务端文件--MessageReceiveInOut文件中,有一段代码需要修改,才能调通。

    代码如下:

       这是由wsdl文件直接生成服务端文件--MessageReceiveInOut的部分代码(生成的文件的前几行):

      public class VodServiceMessageReceiverInOut extends org.apache.axis2.receivers.AbstractInOutMessageReceiver{
    
    
            public void invokeBusinessLogic(org.apache.axis2.context.MessageContext msgContext, org.apache.axis2.context.MessageContext newMsgContext)
            throws org.apache.axis2.AxisFault{
    
            try {
    
            // get the implementation class for the Web Service
            Object obj = getTheImplementationObject(msgContext);
    
            VodServiceSkeleton skel = (VodServiceSkeleton)obj;

    如果同通过客户端调用服务端,需要将上述代码修改为如下:

        public class VodServiceMessageReceiverInOut extends org.apache.axis2.receivers.AbstractInOutMessageReceiver{
    //VodServiceSkeleton为服务端文件的控制类,将他进行私有化,通过反射进行调用
    private VodServiceSkeleton skel = com.allcam.bpc.common.SpringContextHolder.getBean(VodServiceSkeleton.class); public void invokeBusinessLogic(org.apache.axis2.context.MessageContext msgContext, org.apache.axis2.context.MessageContext newMsgContext) throws org.apache.axis2.AxisFault{ try { // get the implementation class for the Web Service // Object obj = getTheImplementationObject(msgContext); // VodServiceSkeleton skel = (VodServiceSkeleton)obj;

    改为以上代码就可以进行相互调用了,小知识点但却很重要。

    直接对比前后代码截图:左边为直接生成代码,右边为修改后调用的代码

    学识尚浅,有问题欢迎指出。

  • 相关阅读:
    剑指offer 整数中1出现的次数(从1到n整数中1出现的次数)
    剑指offer 把数组排成最小的数
    剑指offer 丑数
    剑指offer 字符串的排列
    剑指offer 数组中出现次数超过一半的数字
    剑指offer 最小的K个数
    操作系统 页面置换算法(C++实现)
    剑指offer 二叉搜索树与双向链表
    剑指offer 复杂链表的复制
    操作系统 银行家算法(C++实现)
  • 原文地址:https://www.cnblogs.com/zjdxr-up/p/7543392.html
Copyright © 2020-2023  润新知