use of com.alibaba.csb.ws.sdk.WSClientException in project csb-sdk by aliyun.
the class BindingInterceptor method before.
/* packaged */
List<Handler> before(Object proxy) throws JAXBException {
// 拦截器BindingInterceptor方法调用:before()!");
if (!(proxy instanceof BindingProvider)) {
throw new WSClientException("proxy is not a legal soap client, can not do the interceptor");
}
// put security info into http request headers for over-proxy invocation
setSecrectHeaders((BindingProvider) proxy, wsparams);
// skip this soap header logic
if (HEADERS_INSOAP) {
shh = new SOAPHeaderHandler(wsparams);
BindingProvider bp = (BindingProvider) proxy;
handlers = bp.getBinding().getHandlerChain();
List<Handler> newHandlers = new ArrayList<Handler>();
if (handlers != null) {
newHandlers.addAll(handlers);
}
newHandlers.add(shh);
// tip, must set the handleList again, or the handler will not
// run!!!
bp.getBinding().setHandlerChain(newHandlers);
}
return handlers;
}
use of com.alibaba.csb.ws.sdk.WSClientException in project csb-sdk by aliyun.
the class BindingInterceptor method after.
/* packaged */
public void after(Object proxy) {
// 拦截器BindingInterceptor方法调用:after()!");
if (!(proxy instanceof BindingProvider)) {
throw new WSClientException("proxy is not a legal soap client, can not do the interceptor");
}
// TODO: this is not work, can not clear the new-added handler!
if (shh != null) {
BindingProvider bp = (BindingProvider) proxy;
bp.getBinding().getHandlerChain().remove(shh);
bp.getBinding().setHandlerChain(handlers);
}
}
use of com.alibaba.csb.ws.sdk.WSClientException in project csb-sdk by aliyun.
the class SOAPHeaderHandler method handleMessage.
@Override
public boolean handleMessage(SOAPMessageContext context) {
try {
Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty.booleanValue()) {
SOAPEnvelope envelope = context.getMessage().getSOAPPart().getEnvelope();
SOAPHeader header = envelope.getHeader();
if (header == null)
header = envelope.addHeader();
if (wsParams.getAk() != null) {
Map<String, String> headers = SignUtil.newParamsMap(null, wsParams.getApi(), wsParams.getVersion(), wsParams.getAk(), wsParams.getSk(), wsParams.isTimestamp(), wsParams.isNonce(), WSClientSDK.genExtHeader(wsParams.getFingerPrinter()));
for (Entry<String, String> kv : headers.entrySet()) {
header.addHeaderElement(new QName(HEADER_NS, kv.getKey())).setTextContent(kv.getValue());
dumpHeaders(kv.getKey(), kv.getValue());
}
}
if (wsParams.isMockRequest()) {
header.addHeaderElement(new QName(HEADER_NS, HEADER_MOCK));
dumpHeaders(HEADER_MOCK, "");
}
} else {
// remove the unnecessary response headers
// SOAPEnvelope envelope =
// context.getMessage().getSOAPPart().getEnvelope();
}
} catch (Exception e) {
throw new WSClientException("failed to add soap header", e);
}
return true;
}
Aggregations