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,@WebParam(name="content") String
content,@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,@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#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...