我通过main方法调用SAOP Webservice并且工作正常..但是当我通过名为method的浏览器调用相同的方法时,它会给我以下错误。
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL:
------------工作代码如下---------------------------
public class WSConnectionUtil {
private static final WSConnectionUtil INSTANCE = new WSConnectionUtil();
public SynchronizationServiceWSImpl getSyncServicePort(){
SynchronizationServiceWSImplService service = new SynchronizationServiceWSImplService();
SynchronizationServiceWSImpl servicePort = service.getSynchronizationServiceWSImplPort();
((BindingProvider) servicePort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,getInstance().getSyncUrl());
return servicePort;
}
public static WSConnectionUtil getInstance() {
return INSTANCE;
}
private String getSyncUrl(){
String url = "http://10.2.241.33/synchronize?wsdl";
return url;
}
}
public void syncAll(){
System.out.println("===========syncAll======"+new Date());
SynchronizationRequest request = new SynchronizationRequest();
WSConnectionUtil wsCon = WSConnectionUtil.getInstance();
request.setPosCode("TNCB");
SynchronizationResponse response = wsCon.getSyncServicePort().synchronize(request);
List<String> types = response.getUpdateTypes();
System.out.println("===========types======"+types.size());
}
----------错误代码---------------------
/**
*
* service for login execution
* - user : Contains user id & password
* @param user
* @return
*
*/
@RequestMapping(value = "/login", method = RequestMethod.POST)
public @ResponseBody ModelMap login(@ModelAttribute ("User")User user ){
String username = user.getName();
String password = user.getPassword();
ModelMap model = new ModelMap();
Boolean status = loginService.login(username, password);
if(status == true){
model.put("status", true);
}
return model;
}
public boolean login(String loginUser,String password){
Steward steward = new Steward();
steward.setStewardId(Integer.parseInt(loginUser));
//List<Steward> stewardsList = stewardDao.getStewardsByCriteria(steward);
//if(stewardsList!=null && stewardsList.size()>0){
// steward = stewardsList.get(0);
//}else{
// LOG.error("Cannot Find a Steward for Login : "+loginUser);
// return false;
//}
TouchPosApplication.getApplication().setUser("SYSTEM");
TouchPosApplication.getApplication().setOutletCode("A");
TouchPosApplication.getApplication().setLoginUserId(loginUser);
// final SynchronizationServiceImpl impl = new SynchronizationServiceImpl();
// impl.syncAll();
new Thread(new Runnable() {
private static final long serialVersionUID = -4094418102152819603L;
@Override
public void run() {
while (true) {
long i =0;
try {
i = 1000 * 60 * 1;
Thread.sleep(i);
} catch (InterruptedException e) {
System.out.println("===InterruptedException==========="+e);
}
SyncUtil.synchronizeAutomatic(true);
}
}
}).start();
LOG.info("::::: Successfuly Logged In :"+loginUser);
return true;
}