先导入maven:
<!--访问远程api-->
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.4</version>
</dependency>
java后端代码:
String returnjson = ApiUtils.getErpInterface(jsonStr,"createAdvletterByVSS");
public static String getErpInterface(String json,String method)
throws ServiceException, MalformedURLException {
System.out.print(json);
List<Map> urlList= null;
String strurl = "http://********";
/* if(urlList !=null && urlList.size()>0)
strurl=((Map)urlList.get(0)).get("label").toString();
else
throw new RuntimeException("请维护接口地址!");*/
String invokeResult = "";
Service service = new Service();
try {
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(strurl));
call.setOperationName(method);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
call.addParameter( "arg1", XMLType.XSD_STRING, ParameterMode.IN);
try {
invokeResult = (String) call.invoke(new Object[] {json});
} catch (RemoteException e) {
e.printStackTrace();
}
System.out.print(invokeResult);
} catch (javax.xml.rpc.ServiceException e) {
e.printStackTrace();
}
return invokeResult;
}