我正在尝试从为外部人员开发的Web服务中使用一些方法。当我打电话给他时,我有这个错误:
Access is denied.
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:606)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1741)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2898)
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
org.apache.axis.client.Call.invokeEngine(Call.java:2784)
org.apache.axis.client.Call.invoke(Call.java:2767)
org.apache.axis.client.Call.invoke(Call.java:2443)
org.apache.axis.client.Call.invoke(Call.java:2366)
org.apache.axis.client.Call.invoke(Call.java:1812)
Services.Web.CCIS.BasicHttpBinding_PublicApiServiceStub.getAccountInfo(BasicHttpBinding_PublicApiServiceStub.java:1199)
es.uniway.action.login.LoginAction.execute(LoginAction.java:163)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:453)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:292)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:255)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
nota La traza completa de la causa de este error se encuentra en los archivos de diario de Apache Tomcat/7.0.12.
为什么?这是我的代码:
public String execute() throws Exception {
System.out.println("rrrrrr");
// TODO Auto-generated method stub
logIn=false;
java.net.URL portAddress=null;
String endpoint="";
session = ActionContext.getContext().getSession();
System.out.println("ffffffffffffffffff");
System.out.println("La password es:"+getPassword());
PublicApiServiceProxy publicPort=null;
PublicApiService_Service publicService=null;
//java.net.URL portAddressCloud = new java.net.URL("http://localhost:8080/webServiceCloud2/services/WscloudImpl");
java.net.URL portAddressCloud = new java.net.URL("http://localhost:8080/webServiceCloud2_old/services/WscloudImpl");
WscloudImplServiceLocator wscloudServiceLocator = new WscloudImplServiceLocator();
//WscloudImpl wscloud = wscloudServiceLocator.getWscloudImpl(portAddress);
WscloudImplSoapBindingStub bsStubcloud=null;
bsStubcloud=(WscloudImplSoapBindingStub) wscloudServiceLocator.getWscloudImpl(portAddressCloud);
String url = (servletRequest.getRequestURL()).toString();
endpoint="http://xxx.xxxxx.es/CCIS/Services/PublicApiService.wsdl";
portAddress = new java.net.URL("http://://xxx.xxxxx.es/CCIS/Services/PublicApiService.svc");
publiApi = new PublicApiService_ServiceLocator();
ports=publiApi.getBasicHttpBinding_PublicApiService(portAddress);
BasicHttpBinding_PublicApiServiceStub bsStub=null;
bsStub=(BasicHttpBinding_PublicApiServiceStub) publiApi.getBasicHttpBinding_PublicApiService(portAddress);
session.put("login",logIn);
// ((BasicHttpBinding_PublicApiServiceStub)bsStub).setMaintainSession(true);
if((getUsername().length()==0)||(getPassword().length()==0)){
addActionError("Introduce el login y la password");
session.remove("usuario");
session.remove("password");
bsStub.logout();
return "INPUT";
}
System.out.println(getUsername());
((BasicHttpBinding_PublicApiServiceStub)bsStub).setMaintainSession(true);
logIn=bsStub.logon(getUsername(), getPassword());
System.out.println(logIn);
session.put("login",logIn);
if(logIn){
PapiAccountInfo info=bsStub.getAccountInfo((long)0);
PapiUserInfo[] users=bsStub.getUsers();
System.out.println(users[0].getID());
System.out.println("ID:"+info.getID());
//TRespuestaValidarUsuario resultado=bsStubcloud.validarUsuario(104,86);
TRespuestaValidarUsuario resultado=bsStubcloud.validarUsuario(users[0].getID(),info.getID());
if(resultado.getError()==0){
session.put("ID_CUENTA_SESSION", resultado.getDatosValidarUsuario()[0].getId_cuenta());
session.put("ID_USUARIO_SESSION", resultado.getDatosValidarUsuario()[0].getId_usuario());
session.put("ID_LOGIN_USUARIO_SESSION", resultado.getDatosValidarUsuario()[0].getLogin());
session.put("ID_NIVEL_CUENTA_SESSION",resultado.getDatosValidarUsuario()[0].getNivel_cuenta());
session.put("ID_NOMBRE_CUENTA_SESSION", resultado.getDatosValidarUsuario()[0].getNombre_cuenta());
session.put("ID_DISTRIBUIDOR_SESSION", resultado.getDatosValidarUsuario()[0].getId_distribuidor());
if(resultado.getDatosValidarUsuario()[0].getNivel_cuenta()==1){
System.out.println("Soy mayorista");
setRole("mayorista");
}
if((resultado.getDatosValidarUsuario()[0].getNivel_cuenta()==2)||(resultado.getDatosValidarUsuario()[0].getNivel_cuenta()==7)){
System.out.println("Soy distribuidor");
setRole("distribuidor");
}
if(resultado.getDatosValidarUsuario()[0].getNivel_cuenta()==3){
System.out.println("Soy cliente");
setRole("cliente");
}
return "SUCCESS";
}
String id_login=session.get("ID_LOGIN_USUARIO_SESSION").toString();
String id_nivel_cuenta=session.get("ID_NIVEL_CUENTA_SESSION").toString();
TRespuestaLogo respuesta=bsStubcloud.obtener_Logo(Integer.valueOf(id_login),Integer.valueOf(id_nivel_cuenta));
byte [] logo=respuesta.getLogo();
request =(HttpServletRequest) ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
//Comentar lo que me dijo Phill
//((BindingProvider)bsTub).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
Call call=bsStub._getCall();
MessageContext ctx=call.getMessageContext();
if(ctx==null){
System.out.println("Holaa");
}
Iterator i=ctx.getAllPropertyNames();
while(i.hasNext()){
System.out.println(i.next());
}
ctx.getProperty("Cookie");
ctx.setUsername(getUsername());
ctx.setPassword(getPassword());
session.put("contexto", ctx);
session.put("puerto", bsStub);
}else{
TDatosRetorno proveedor=bsStubcloud.validar_Proveedor(getUsername(),getPassword());
if(proveedor.getError()==0){
System.out.println("Entro como proveedor");
session.put("ID_CUENTA_SESSION", 0);
session.put("ID_USUARIO_SESSION", "Uniway");
session.put("ID_LOGIN_USUARIO_SESSION", "Uniway");
session.put("ID_NIVEL_CUENTA_SESSION",0);
session.put("ID_NOMBRE_CUENTA_SESSION", "Uniway");
session.put("ID_DISTRIBUIDOR_SESSION", 0);
request =(HttpServletRequest) ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
//Comentar lo que me dijo Phill
//((BindingProvider)bsTub).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
Call call=bsStub._getCall();
MessageContext ctx=call.getMessageContext();
if(ctx==null){
System.out.println("Holaa");
}
Iterator i=ctx.getAllPropertyNames();
while(i.hasNext()){
System.out.println(i.next());
}
ctx.getProperty("Cookie");
ctx.setUsername(getUsername());
ctx.setPassword(getPassword());
session.put("contexto", ctx);
session.put("puerto", bsStub);
return "SUCCESSPROV";
}else{
addActionError("No existe dicho usuario en nuestra base de datos");
session.remove("usuario");
session.remove("login");
return "INPUT";
}
}
publicPort=new PublicApiServiceProxy(endpoint);
String login=publicPort.getEndpoint();
System.out.println("LogIn es: "+logIn);
if(logIn){
return "SUCCESS";
}
if(!logIn){
addActionError("Error al logarte");
session.remove("username");
session.remove("password");
bsStub.logout();
return "INPUT";
}
return "SUCCESS";
}
开发此ws的人告诉我:GetAccountInfo操作仅在正常操作下未登录的请求中生成“拒绝访问”。您是否可以使用登录操作验证您是否正在登录,并且在服务呼叫之间传递身份验证cookie?我有((BasicHttpBinding_PublicApiServiceStub)bsStub).setMaintainSession(true);为什么我有这个错误?感谢
答案 0 :(得分:0)
我想我可能遇到了类似的问题。我正在调用一些服务,其中验证步骤进行得很顺利,但我无法在其他服务上使用我的sessionId,我总是得到一个拒绝访问的消息。很长一段时间后,我在http://www.nsftools.com/stubby/ApacheAxisClientTips.htm找到了我的解决方案 除了设置setMaintainSession(true)之外,我还必须执行以下操作:
CompanyServiceLocator cl = new CompanyServiceLocator();
cl.setMaintainSession(true);
CompanyServiceSoap css = cl.getCompanyServiceSoap();
((Stub)css)._setProperty(HTTPConstants.HEADER_COOKIE, "ASP.NET_SessionId="+sessionId);
css.getCountryList(); //Success after adding the HEADER_COOKIE-line. :-D
其中sessionId是我在验证自己时收到的sessionId。您可能必须将ASP._Net_SessionId替换为cookie的名称。