Axis1.4 在weblogic9.2中报 (401)Unauthorized 的处理
WebService server 在tomcat上部署,client在Weblogic9.2中部署,在使用安全方式调用的时候,报错:
(401)Unauthorized at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
如果server 和client 都在 tomcat,则不存在问题。
webService 的 client 代码是有 WDSL2JAVA 自动产生的代码。
经过多方跟踪,发现在client构造的java.net.URL 实例的 toString() 在tomcat下输出如下:
http://7564945504235898643:123@192.168.0.175:9080/tunnel-web/secure/axis/Plat_UserService
在weblogic下输出如下:
http://192.168.0.175:9080/tunnel-web/secure/axis/Plat_UserService
多方查找,也找不到原因。后来通过手工创建call,可以调用,代码如下:
String wsdlUrl = " http://192.168.0.175:9080/tunnel-web/secure/axis/BkPlat_UserService?wsdl " ; String nameSpaceUri = " urn:http.service.system.platform.xx.com " ; try { Service service = new Service(); Call call = null ; call = (Call) service.createCall(); call.setUsername( " 7564945504235898643 " ); call.setPassword( " 123 " ); org.apache.axis.description.OperationDesc oper; org.apache.axis.description.ParameterDesc param; oper = new org.apache.axis.description.OperationDesc(); oper.setName( " getUserById " ); param = new org.apache.axis.description.ParameterDesc( new javax.xml.namespace.QName( "" , " userId " ), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName( " http://www.w3.org/2001/XMLSchema " , " long " ), long . class , false , false ); oper.addParameter(param); oper.setReturnType( new javax.xml.namespace.QName( " http://model.system.platform.xxx.com " , " UserSoap " )); oper.setReturnClass(com.xxx.platform.client.system.model.UserSoap. class ); oper.setReturnQName( new javax.xml.namespace.QName( "" , " getUserByIdReturn " )); oper.setStyle(org.apache.axis.constants.Style.RPC); oper.setUse(org.apache.axis.constants.Use.ENCODED); call.setOperation(oper); call.setOperationName( new QName(nameSpaceUri, " getUserById " )); call.setTargetEndpointAddress( new java.net.URL(wsdlUrl)); try { java.lang.Object _resp = call.invoke( new java.lang.Object[] {Long.valueOf( " 7564945504235898643 " )}); if (_resp instanceof java.rmi.RemoteException) { throw (java.rmi.RemoteException)_resp; } else { try { Object user = (com.xxx.platform.client.system.model.UserSoap) _resp; } catch (java.lang.Exception _exception) { Object user = (com.xxx.platform.client.system.model.UserSoap) org.apache.axis.utils.JavaUtils.convert(_resp, com.xxx.platform.client.system.model.UserSoap. class ); } } } catch (org.apache.axis.AxisFault axisFaultException) { throw axisFaultException; } } catch (Exception e){ log.warn( " test error: " , e); }
然后下载axis1.4的源代码,对源代码做中org.apache.axis.wsdl.toJava.JavaStubWriter 类的产生createCall的代码做如下修正:
使得在url中找不到用户信息的时候,通过userInfo中获取用户信息。
修改后产生的Stub代码如下:
// add by gongjan protected org.apache.axis.client.Call setUserInfo(org.apache.axis.client.Call call) throws java.rmi.RemoteException { if(super.cachedUsername == null){ if(super.cachedEndpoint != null){ String userInfo = super.cachedEndpoint.getUserInfo(); if(userInfo == null) return call; String[] str = userInfo.split(":"); if(str != null && str.length == 2){ String userName = str[0]; String password = str[1]; call.setUsername(userName); call.setPassword(password); } } }else{ call.setUsername(super.cachedUsername); if (super.cachedPassword != null) { call.setPassword(super.cachedPassword); } } return call; } // end by wiwinderai
JavaStubWriter.java
Axis1.4 在weblogic9.2中报 (401)Unauthorized 的处理相关推荐
- method DESCRIBE failed: 401 Unauthorized
[rtsp @ 000001dc99212880] method DESCRIBE failed: 401 Unauthorized warning: Error opening file (/bui ...
- python错误解决方案之关于报urllib2.HTTPError: HTTP Error 401: Unauthorized错误问题
报错信息: Traceback (most recent call last): File "<pyshell#18>", line 1, in <modul ...
- Jenkins中连接Git仓库时提示:error: The requested URL returned error: 401 Unauthorized while accessing
场景 在Jenkins中新建任务后,在源码管理中选择Git,并且通过用户名和密码的 凭证方式连接到Git仓库时提示: error: The requested URL returned error: ...
- EasyNVR摄像机网页无插件直播方案H5前端构建之:关于接口调用常见的一些问题(401 Unauthorized)...
背景分析 最近在使用EasyNVR的过程中,很多小伙伴咨询关于接口调用的问题,初步判断应该是遇到权限问题(401 Unauthorized).EasyNVR为第三方系统和应用提供了标准的API接口,方 ...
- 访问CrmService遇到HTTP status 401 Unauthorized的问题
在使用CrmService往数据库批量Create记录时,为了提高性能经常会设置PreAuthenticate为true,但是如果在创建记录前,往往需要RetrieveMultiple其他实体来查找l ...
- python的request请求401_Python模拟HTTPS请求返回HTTP 401 unauthorized错误
Python模拟HTTPS请求返回HTTP 401 unauthorized错误 开始是使用的 httplib模块,代码如下: header = {"Content-type": ...
- error: The requested URL returned error: 401 Unauthorized while accessing
在使用git pull.git push.git clone会报类似如下的错误: error: The requested URL returned error: 401 Unauthorized ...
- nexus私服传项目-401 Unauthorized
在将本地项目传到nexus私服时,切记要记得写正确私服的**<username>和 <password>**,不然就会报没有权限的错误 **401 Unauthorized** ...
- 403 Forbidden vs 401 Unauthorized HTTP 响应
问: 对于存在的网页,但用户没有足够的权限(他们没有登录或不属于正确的用户组),应该提供什么正确的 HTTP 响应? 401 Unauthorized? 403 Forbidden? 还有什么? 到目 ...
最新文章
- Oracle恢复删除的数据
- 每天一道LeetCode-----删除链表倒数第n个节点
- android 官方教程中文版
- subroutines of perl
- python基本语法:字典
- 【Jquery系列】之DOM属性
- 文档丨暴力破解性能问题
- python做审计底稿视频_最新Python教学视频,每天自学俩小时,让你offer拿到手软...
- Linux下的C++ socket编程实例
- group by 分组函数 的用法
- [转载] python中字典中追加_python 中字典中的删除,pop 方法与 popitem 方法
- ps随意改变图层形态
- 《老友记》第一季第二集精读笔记
- scrapy框架之spider
- 白岩松:不平静,就不会幸福 幸福在哪里(代序)
- UVa 10041 - Vito's Family
- 泰迪云课堂大数据培训平台业务介绍
- ZBrush中的三种对称类型的完美运用
- 解决 Vmware 虚拟机安装linux系统无法联网的的问题
- Csharp 简单操作Word模板文件