WebLogic 上WebServices 总是提示 401 Unauthorized 异常的一种
发布时间:2020-12-16 23:57:38 所属栏目:安全 来源:网络整理
导读:异常信息: AxisFault ?faultCode: {http://xml.apache.org/axis/}HTTP ?faultSubcode:? ?faultString: (401)Unauthorized ?faultActor:? ?faultNode:? ?faultDetail:? {}:return code: ?401 lt;!DOCTYPE HTML PUBLIC quot;-//W3C//DTD HTML 4.0 Draft//ENquo
异常信息: AxisFault ?faultCode: {http://xml.apache.org/axis/}HTTP ?faultSubcode:? ?faultString: (401)Unauthorized ?faultActor:? ?faultNode:? ?faultDetail:? {}:return code: ?401 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Draft//EN"> <HTML> <HEAD> <TITLE>Error 401--Unauthorized</TITLE> </HEAD> <BODY bgcolor="white"> <FONT FACE=Helvetica><BR CLEAR=all> <TABLE border=0 cellspacing=5><TR><TD><BR CLEAR=all> <FONT FACE="Helvetica" COLOR="black" SIZE="3"><H2>Error 401--Unauthorized</H2> </FONT></TD></TR> </TABLE> <TABLE border=0 width=100% cellpadding=10><TR><TD VALIGN=top WIDTH=100% BGCOLOR=white><FONT FACE="Courier New"><FONT FACE="Helvetica" SIZE="3"><H3>From RFC 2068 <i>Hypertext Transfer Protocol -- HTTP/1.1</i>:</H3> </FONT><FONT FACE="Helvetica" SIZE="3"><H4>10.4.2 401 Unauthorized</H4> </FONT><P><FONT FACE="Courier New">The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.46) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials,then the 401 response indicates that authorization has been refused for those credentials. If the 401 response contains the same challenge as the prior response,and the user agent has already attempted authentication at least once,then the user SHOULD be presented the entity that was given in the response,since that entity MAY include relevant diagnostic information. HTTP access authentication is explained in section 11.</FONT></P> </FONT></TD></TR> </TABLE> </BODY> </HTML> {http://xml.apache.org/axis/}HttpErrorCode:401 (401)Unauthorized at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744) at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2765) at org.apache.axis.client.Call.invoke(Call.java:2748) at org.apache.axis.client.Call.invoke(Call.java:2424) at org.apache.axis.client.Call.invoke(Call.java:2347) at org.apache.axis.client.Call.invoke(Call.java:1804) at cn.test.WSClient.callLocalhost(WSClient.java:43) at cn.test.WSClient.main(WSClient.java:18) 操作步骤: 1、检查WebLogic控制台标记,搜索 Security,检查当前WLS的Realm名字 例如:myrealm; <20XX-12-5 下午03时14分25秒 CST> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.> 2、以上异常提示表示WebServices请求身份认证没有通过,不允许访问服务器资源,此时调用方式必须设置访问账号、以及密码,服务器将拒绝请求; String endpoint = "http://localhost:7001/MyServicesWeb/services/SayHello"; Service service = new Service(); Call call = (Call) service.createCall(); //设置Security Realm方式一 // ? ? ? ? ? ?//远程调用用户名设置(HTTP统一认证账号) // ? ? ? ? ? ?call.setUsername("weblogic");//wstest/hb_hsxf // ? ? ? ? ? ?//远程调用密码设置,黄石公众诉求(HTTP统一认证密码) // ? ? ? ? ? ?call.setPassword("passw0rd"); //设置Security Realm方式二 call.setProperty(org.apache.axis.client.Call.USERNAME_PROPERTY,"weblogic"); //账号 call.setProperty(org.apache.axis.client.Call.PASSWORD_PROPERTY,"passw0rd1");//密码 call.setTargetEndpointAddress(new java.net.URL(endpoint)); //设置远程调用方法路径及方法名称 call.setOperationName(new QName("urn:SayHello","getHello")); //传入xml文档字符串,返回数据校验错误字符串 //String d = (String) call.invoke(new Object[] {Document.asXML()}); String d = (String) call.invoke(new Object[]{"本地调用"}); System.out.println("Debug-Info: WSClient.callLocalhost Response $d>> "+d);(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |