[color=green]服务端Service[/color]
[color=green]通过WSDL生成的客户端代码如图:[/color][img]http://dl.iteye.com/upload/picture/pic/115831/df01ceb4-b7e4-3552-a3ae-0dacee7c7113.jpg[/img]
[color=green]客户端调用代码[/color]
package com.demo.service.impl;
import com.demo.service.UserService;
public class UserServiceImpl implements UserService {
@Override
public int Login(String username, String password) {
// TODO Auto-generated method stub
if (username.equals("a") && password.equals("a")) {
return 1;
}
return 0;
}
}
[color=green]通过WSDL生成的客户端代码如图:[/color][img]http://dl.iteye.com/upload/picture/pic/115831/df01ceb4-b7e4-3552-a3ae-0dacee7c7113.jpg[/img]
[color=green]客户端调用代码[/color]
package com.demo.service.impl;
import java.rmi.RemoteException;
public class Client {
public static void main(String[] args) throws RemoteException {
String target = "http://localhost:8080/axis2/services/UserService";
UserServiceStub stub = new UserServiceStub(target);
Login login = new Login();
login.setUsername("a");
login.setPassword("a");
LoginResponse loginResponse = stub.login(login);
// 调用WebService得到的返回值1/0
System.out.println(loginResponse.get_return());
}
}