When we have more permissions to intercept the WebService interface to determine if it is possible to invoke one of my demo
First we write an interception class
Import javax.xml.soap.SOAPException;
Import Org.apache.cxf.interceptor.Fault;
Import Org.apache.cxf.message.Message;
Import org.apache.cxf.message.MessageContentsList;
Import Org.apache.cxf.phase.AbstractPhaseInterceptor;
Import Org.apache.cxf.phase.Phase;
Import org.springframework.beans.factory.annotation.Autowired;
Import Com.sinotrans.eaiconsole.model.EsUserModel;
Import Com.sinotrans.eaiconsole.user.service.LoginManager;
public class Webserviceuserauthorityinterceptor extends Abstractphaseinterceptor<message> {
@Autowired
Loginmanager Loginmanager;
Public Webserviceuserauthorityinterceptor () {
Super (Phase.pre_invoke);
}
public void Handlemessage (Message message) throws Fault {//Specify CXF get client HttpServletRequest
// :
Http-request;
Messagecontentslist contents = Messagecontentslist
. getcontentslist (message);
String userName = "", pwd = "";
if (contents! = null && contents.size () > 0) {
UserName = (String) contents.get (0);
PWD = (String) contents.get (1);
Esusermodel eum = loginmanager.longinwebserviceuserauthority (
UserName, PWD);
if (null = = Eum) {
SoapException Soapexc = new SoapException ("User name password Authentication failed");
throw new Fault (SOAPEXC);
}
} else {
SoapException Soapexc = new SoapException ("parameter information not entered");
throw new Fault (SOAPEXC);
}
}
}
Then we configure the following in the CXF
Our interception class is injected into the
<bean id= "Inmessageinterceptor"
class= "Com.sinotrans.eaiconsole.Interceptor.WebServiceUserAuthorityInterceptor" >
</bean>
Inject our interception class into a method that requires interception
<jaxws:endpoint id= "Lmswebservice"
Implementor= "Com.sinotrans.eaiconsole.service.impl.LMSWebServiceImpl"
address= "/lmswebservice" >
<jaxws:inInterceptors>
<ref bean= "Inmessageinterceptor"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
WebService Intercept.