axis客户端调用用axis方式发布的接口,报错:{http://xml.apache.org/axis/}HttpErrorCode:404
原因是:
如下的address访问不了。在浏览器中输入http://127.0.0.1:8080/testProject/services/myService?wsdl,看能不能拿到wsdl文件。
public String XXX(String input) {
String address= "http://127.0.0.1:8080/testProject/services/myService?wsdl";
String action= "XXX";
org.apache.axis.client.Service service = new org.apache.axis.client.Service();
Call call;
try {
call = (Call) service.createCall();
try {
call.setTargetEndpointAddress(new java.net.URL(address));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
call.setOperationName(action);
// Object[] obj;
String result;
try {
result = (String) call.invoke(new Object[] { input});
return result;
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}