AXIOM 1.2.13到1.2.20迁移

时间:2017-09-07 16:04:19

标签: axiom

I have the following Java method using AXIOM 1.2.13:

private OMElement createSecurityHeader(String username, String password) {
OMNamespaceImpl wsseNS = new OMNamespaceImpl(WSSE_NS, WSSE_PREFIX);
OMFactory factory = new SOAP11Factory();
OMElementImpl securityHeader;
OMElementImpl usernameTokenElement;
OMElementImpl usernameElement;
OMElementImpl passwordElement;

// create the Security header block
securityHeader = new OMElementImpl("Security", wsseNS, factory);
securityHeader.addAttribute("mustUnderstand", "1", null);

// nest the UsernameToken in the Security header
usernameTokenElement = new OMElementImpl(USERNAME_TOKEN_LN, wsseNS, securityHeader, factory);

// nest the Username and Password elements
usernameElement = new OMElementImpl(USERNAME_LN, wsseNS, usernameTokenElement, factory);
usernameElement.setText(username);

passwordElement = new OMElementImpl(PASSWORD_LN, wsseNS,usernameTokenElement, factory);
passwordElement.setText(password);
passwordElement.addAttribute(PASSWORD_TYPE_ATTR, PASSWORD_TEXT, null);

return securityHeader;
}
}

我想迁移此代码以使用AXIOM 1.2.20。

寻找解决方案或建议使用哪些资源来执行此操作?

1 个答案:

答案 0 :(得分:0)

使用OMAbstractFactory.getSOAP11Factory()获取SOAPFactory实例,然后重写代码以使用工厂方法,直到不再有对内部实现类的引用。结果代码将适用于两个Axiom版本。