首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

Xfire SOAP Header设立

2012-08-25 
Xfire SOAP Header设置package testimport org.codehaus.xfire.MessageContextimport org.codehaus.xfir

Xfire SOAP Header设置

package test;import org.codehaus.xfire.MessageContext;import org.codehaus.xfire.handler.AbstractHandler;import org.jdom.Element;public class ClientAuthenticationHandler extends AbstractHandler {     private String username = null;      private String password = null;      public ClientAuthenticationHandler() {      }      public ClientAuthenticationHandler(String username,String password) {          this.username = username;          this.password = password;      }      public void setUsername(String username) {          this.username = username;      }      public void setPassword(String password) {          this.password = password;      }      public void invoke(MessageContext context) throws Exception {          //为SOAP Header构造验证信息         Element el = new Element("header");          context.getOutMessage().setHeader(el);          Element auth = new Element("AuthenticationToken");          Element username_el = new Element("Username");          username_el.addContent(username);          Element password_el = new Element("Password");          password_el.addContent(password);          auth.addContent(username_el);          auth.addContent(password_el);          el.addContent(auth);      } }
?

热点排行