【发布时间】:2020-07-18 06:07:39
【问题描述】:
我正在尝试使用axis1.4 客户端和java7 调用Web 服务,我可以使用soap ui 添加Auth 标头,但是当我通过代码尝试它时,我得到来自服务器的UnAthurized 401 响应。 主要问题是 wsdl 文件中未定义安全标头。所以我公开了soap项目并找出了一些标题,例如:
<con:credentials>
<con:username>sarmayeh_gsb</con:username>
<con:password>Sarmayeh@gsb123</con:password>
<con:domain>estelamwebservice.nocservices.org/iws/Estelam</con:domain>
<con:selectedAuthProfile>Basic</con:selectedAuthProfile>
<con:addedBasicAuthenticationTypes>Basic</con:addedBasicAuthenticationTypes>
<con:authType>Global HTTP Settings</con:authType>
</con:credentials>
如何在我的代码中添加它?
我试过类似的东西
EstelamLocator wsLocator = new EstelamLocator();
logger.info("creating locateor...");
EstelamPort ws = wsLocator.getEstelamPort(new URL("http://10.0.233.254/sabteahval/proxy/SabteAhvalPS?wsdl"));
//add SOAP header for authentication
SOAPHeaderElement authentication = new SOAPHeaderElement("http://est","Authentication");
SOAPHeaderElement user = new SOAPHeaderElement("http://est","User", service_user);
SOAPHeaderElement password = new SOAPHeaderElement("http://est","Password", service_pass);
authentication.addChild(user);
authentication.addChild(password);
Estelam3TRequest re= new Estelam3TRequest();
re.setBirthDate("13750427");
re.setBirthDate("0019317859");
logger.info("creat authentication...");
((org.apache.axis.client.Stub)ws).setHeader(authentication);
ws.getEstelam3T("Bksr","Bk@Sr-0513","36571","915DE0DEAD1",re);
但错误仍然存在。 任何帮助都将不胜感激。
【问题讨论】:
-
请去掉真实的用户名和密码,使用假的
标签: java web-services axis soap-client