长沙大猫 2015-08-05 07:46 采纳率: 0%
浏览 1387

AXIS1环境下调用AXIS2服务端问题

我的项目现在是用的AXIS1的环境但是想调用AXIS2的服务端.我用的RPC的方式.每次调用都会报出org.apache.axis2.AxisFault: String index out of range: -12的错误.在纯AXIS2的环境下是可以的.我的代码如下
import javax.xml.namespace.QName;

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;

public class test {
/**
* RPC调用AXIS2 webservice
* @param endpoint 服务地址 如:http://192.168.212.192:8090/jyedi/services/ediService?wsdl
* @param localPart 方法名 如sendMessageLD2WMS
* @param opArgs 方法参数 如Object[] opArgs = new Object[] { param };
* @param namespaceURI 命名空间 如 :targetNamespace="http://impl.services.service.server.edi.vtradex.com">
* @param opReturnType 返回类型 如字符串:Class[] opReturnType = new Class[] { String[].class };
* @throws org.apache.axis2.AxisFault
*/
public static String axis2RPCInvoke(String endpoint,String localPart,Object[] opArgs,String namespaceURI,Class[] opReturnType) throws org.apache.axis2.AxisFault, AxisFault
{
Object[] ret = null;
try
{
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
EndpointReference targetEPR = new EndpointReference(endpoint);
options.setTo(targetEPR);
QName opQName = new QName(namespaceURI, localPart);
ret = serviceClient.invokeBlocking(opQName, opArgs, opReturnType);
System.out.println(((String[]) ret[0])[0]);
}
catch (AxisFault e)
{
e.printStackTrace();
}
return ((String[]) ret[0])[0];
}
}

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 MATLAB中streamslice问题
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序