axis2调用xfire开发的webservice服务接口

爱笑的眼睛 2012-05-30 02:49:12
对方使用xfire开发了带有soapheader验证的webservice:在soapheader中附带用户名和密码信息,服务端解析;现在在我这一端需要使用axis2调用webservice服务,请问如如何将用户名密码信息添加到soapheader中?我调用webservice服务的代码如下:
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:8889/axis2/services/SimpleService?wsdl");
options.setTo(targetEPR);
QName opAddEntry = new QName("http://ws.apache.org/axis2", "getMyArea");
serviceClient.invokeBlocking(opAddEntry, new Object[]{},new Class[]{String.class})。
对方服务端接受的代码:
public class AuthenticationHandler extends AbstractHandler {

public void invoke(MessageContext cfx) throws Exception {

if (cfx.getInMessage().getHeader() == null) {
throw new org.codehaus.xfire.fault.XFireFault("请求必须包含验证信息",
org.codehaus.xfire.fault.XFireFault.SENDER);
}
final Namespace TOKEN_NS = Namespace.getNamespace("",
"http://webservice.report.enation.com");
Element token = cfx.getInMessage().getHeader().getChild(
"AuthenticationToken", TOKEN_NS);
if (token == null) {
throw new org.codehaus.xfire.fault.XFireFault("请求必须包含身份验证信息",
org.codehaus.xfire.fault.XFireFault.SENDER);
}
String username = token.getChild("Username", TOKEN_NS).getValue();
String password = token.getChild("Password", TOKEN_NS).getValue();
System.out.println(username+"/"+password);
...全文
590 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧