[jboss-user] [JBossWS] - hlep me: Authorization EJB3 webservice client

iloveyou0222 do-not-reply at jboss.com
Wed Sep 10 05:23:42 EDT 2008


How to join the authorized client information


  | @Stateless 
  | @WebService
  | @RolesAllowed({"AdminUser"})
  | public class SupportInterfaceBean implements SupportInterfaceBeanRemote {
  | 	
  | 	@EJB(beanName = "ChatContentFacade") ChatContentFacadeLocal chatContentFacadeLocal;//å¿
需为Bean的本地接口,不能是远程接口
  | 	@EJB(beanName = "ChatFacade") ChatFacadeLocal chatFacadeLocal;
  | 	
  | 	@WebMethod(operationName="sendMessage")
  | 	public Boolean sendMessage(@WebParam(name="chatId") Integer chatId, at WebParam(name="content") String content, at WebParam(name="sndObject") String sndObject) {
  | 		LogUtil.log("发送聊天å†
容消息", Level.INFO, null);
  | 		ChatContent chatContent = new ChatContent();
  | 		chatContent.setChat(chatFacadeLocal.findById(chatId));
  | 		chatContent.setContent(content);
  | 		chatContent.setIsRead(false);
  | 		chatContent.setSndObject(Short.parseShort(sndObject));
  | 		return chatContentFacadeLocal.save(chatContent);
  | 	} 
  | 	
  | 	@WebMethod(operationName="accessMessage")
  | 	public List<WsChatContent> accessMessage(@WebParam(name="chatId") Integer chatId, at WebParam(name="sndObject") String sndObject) {
  | 		LogUtil.log("获取指定条件的聊天å†
容", Level.INFO, null);
  | 		String sqlString = "select * from ChatContent model where model.isRead=0 and model.ChatID=" + chatId + " and model.sndObject='" + sndObject + "'";
  | 		List<ChatContent> list = chatContentFacadeLocal.query(sqlString, null, null);
  | 		List<WsChatContent> results = new ArrayList<WsChatContent>();
  | 		for(ChatContent chatContent : list){
  | 			WsChatContent wsObj = new WsChatContent();
  | 			wsObj.setChatContentId(chatContent.getChatContentId());
  | 			wsObj.setContent(chatContent.getContent());
  | 			wsObj.setIsRead(chatContent.getIsRead());
  | 			wsObj.setSndObject(chatContent.getSndObject().toString());
  | 			results.add(wsObj);
  | 			chatContent.setIsRead(true);
  | 			chatContentFacadeLocal.update(chatContent);
  | 		}
  | 		return results;
  | 	}
  | 
  | }
  | 


  | // TODO Auto-generated method stub
  | 		SupportInterfaceBean proxy = new SupportInterfaceBeanService().getSupportInterfaceBeanPort();
  | 		BindingProvider bindProvider = (BindingProvider) proxy;
  | 		Map<String, Object> reqCtx = bindProvider.getRequestContext();
  | 
  | 		//reqCtx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "/SupportInterfaceBeanService/SupportInterfaceBean");
  | 		reqCtx.put(BindingProvider.USERNAME_PROPERTY, "lihuoming");
  | 		reqCtx.put(BindingProvider.PASSWORD_PROPERTY, "123456");
  | 		reqCtx.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
  | 		System.out.println(proxy.accessMessage(1, "1"));
  | 


  | xception in thread "main" javax.xml.ws.soap.SOAPFaultException: Authorization failure
  | 	at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:188)
  | 	at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:108)
  | 	at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
  | 	at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
  | 	at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
  | 	at $Proxy34.accessMessage(Unknown Source)
  | 	at com.ewke.ejb.ws.Test.main(Test.java:25)
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4175519#4175519

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4175519




More information about the jboss-user mailing list