调用了两天没调用成功的webservice接口,发网上让大神看看有没有什么问题。
先贴一张WSDL图片:
下面是我的JAVA调用代码:
public static void importTest() throws Exception{
String content = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n" +
"\n" +
" \n" +
"\t\n" +
"\t 60140000993\n" +
"\t 60140000993BJ\n" +
"\t 航空\n" +
"\t 北京2016-06-22T17:30:57.6373075+08:00\n" +
"\t 离站转运\n" +
"\t 始发端(上海)发出\n" +
"\t\n" +
" \n" +
"\n";
try {
// 创建一个服务
org.apache.axis.client.Service service = new org.apache.axis.client.Service();
//创建一个call对象
Call call = (Call) service.createCall();
// 远程调用路径
call.setTargetEndpointAddress(new URL("http://127.0.0.1/api/WebService/ImportFreightInfo.asmx"));
// ******************
call.setSOAPActionURI("http://127.0.0.1/Import");
// 调用的方法名
call.setOperationName("Import");
// 设置参数名:
call.addParameter( "xml", // 参数名
org.apache.axis.encoding.XMLType.XSD_STRING, // 参数类型:String
javax.xml.rpc.ParameterMode.IN); // 参数模式:'IN' or 'OUT'
// 设置返回值类型:
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING); // 返回值类型:String
// 远程调用
String result = (String) call.invoke(new Object[]{content});
System.out.println(result);//打印字符串
} catch (Exception ex) {
ex.printStackTrace();
}
}
麻烦大神帮忙看下是不是因为请求参数或其他原因造成的,谢谢!