Client client = ((XFireProxy) ProxygetInvocationHandler(service))getClient();
clientaddOutHandler(new DOMOutHandler());
Properties config = new Properties();
// Action to perform : user token
configsetProperty(WSHandlerConstantsACTION, WSHandlerConstantsUSERNAME_TOKEN);
// Password type : plain text
configsetProperty(WSHandlerConstantsPASSWORD_TYPE, WSConstantsPW_TEXT);
// for hashed password use:
//propertiessetProperty(WSHandlerConstantsPASSWORD_TYPE, WSConstantsPW_DIGEST);
// User name to send
configsetProperty(WSHandlerConstantsUSER, "serveralias");
// Callback used to retrive password for given user
configsetProperty(WSHandlerConstantsPW_CALLBACK_CLASS, PasswordHandlerclassgetName());
clientaddOutHandler(new WSS4JOutHandler(properties));
servicedoSomething()
-------------------------------------------------------------------------------------------------
public class PasswordHandler implements CallbackHandler {
private Map passwords = new HashMap();
public PasswordHandler() {
passwordsput("serveralias", "aliaspass");
passwordsput("client-344-839","client344Password");
}
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
String id = pcgetIdentifer();
pcsetPassword((String) passwordsget(id));
}
}
--------------------------------------------
要用到 wss4j 和 bcprov ,如果仅仅是令牌验证的话,可以不用 bcprov,如果做签名和消息级加密的话,就必须要用到 bcprov 或是其他的安全包了添加SOAP头之前的请求格式如下:
[html] view plaincopy
<xml version='10' encoding='utf-8'>
<soapenv:Envelope xmlns:soapenv=">终于搞定了方法如下[] [] $strHeaderComponent_Session = "ghdsfsdf04d468f1772f95fgd1bf2b";[] $objVar_Session_Inside = new SoapVar($strHeaderComponent_Session, XSD_ANYXML, null, null, null);[] $objHeader_Session_Outside = new SoapHeader(' >直接添加应用,系统会生成Soapheader啊,
没有吗?
生成一个webservice代理,这个代理有一个方法可以设置Soapheader,不需要添加
客户端代理类上应该有SoapHeader属性
axis2 修改 SOAPHeader:
SendSmsServiceStub stub = new SendSmsServiceStub(">欢迎分享,转载请注明来源:内存溢出
评论列表(0条)