当前位置: 首页 > news >正文

山东外贸建站平面设计模板素材网站

山东外贸建站,平面设计模板素材网站,莱州网站设计,网站建设项目甘特图使用Eclipse自动生成Soap Client的代码 在项目按右键#xff0c;选择New - Other -Web Services - Web Service Client#xff0c;进入向导。 加入自有代码#xff0c;例如加入Envelope Header 在xxxxStub.java文件相应的方法中加入#xff1a; public com.…使用Eclipse自动生成Soap Client的代码 在项目按右键选择New - Other -Web Services - Web Service Client进入向导。 加入自有代码例如加入Envelope Header 在xxxxStub.java文件相应的方法中加入 public com.example.api.ApiStatus.EchoResponse echo(com.example.api.ApiStatus.Echo echo) throws java.rmi.RemoteException {if (super.cachedEndpoint null) {throw new org.apache.axis.NoEndPointException();}org.apache.axis.client.Call _call createCall();_call.setOperation(_operations[0]);_call.setUseSOAPAction(true);_call.setSOAPActionURI();_call.setEncodingStyle(null);_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);_call.setOperationName(new javax.xml.namespace.QName(, echo));setRequestHeaders(_call);setAttachments(_call);//这里是加入的Header的内容SoapUtils.addAuthSoapHeader(_call); try { 。。。。。。 public class SoapUtils {private static final Logger log LogManager.getLogger();private static SOAPFactory soapFactory;static{try {soapFactory SOAPFactory.newInstance();} catch (SOAPException e) {log.fatal([FATAL] create SOAP Factory error : {},e.toString());}}//参考http://blog.csdn.net/oscar999/article/details/40340819private static SOAPHeaderElement createDcpSoapHeader(String userName, String password){try {String AUTH_PREFIX wsse;String AUTH_NS http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd;SOAPElement wsSecHeaderElm soapFactory.createElement(Security, AUTH_PREFIX, AUTH_NS);SOAPElement userNameTokenElm soapFactory.createElement(UsernameToken, AUTH_PREFIX, AUTH_NS);SOAPElement userNameElm soapFactory.createElement(Username, AUTH_PREFIX, AUTH_NS);SOAPElement passwdElm soapFactory.createElement(Password, AUTH_PREFIX, AUTH_NS);userNameElm.addTextNode(userName);passwdElm.addTextNode(password);userNameTokenElm.addChildElement(userNameElm);userNameTokenElm.addChildElement(passwdElm);wsSecHeaderElm.addChildElement(userNameTokenElm);SOAPHeaderElement soapHeaderElement new SOAPHeaderElement(wsSecHeaderElm);soapHeaderElement.setMustUnderstand(true);return soapHeaderElement;} catch (Exception e) {return null;}}public static void addAuthSoapHeader(org.apache.axis.client.Call call,String userName, String password){SOAPHeaderElement header createDcpSoapHeader(userName,password);if(header ! null)call.addHeader(header);} } 更好的方式还可以参考 Web Service SOAP Client 设置 SOAP Header那里给出更通用的解决方式而这里需要对每个接口都进行设置。主要是了解一下soap client的代码。 网络出现问题多次重发的实现 利用Java的Function类在SoapUtils实现通用的多次重发方法。 public class SoapUtils {private static final Logger log LogManager.getLogger();......//在log上显示错误并判断是否因为网络连接问题而需要重复public static boolean showAndCheckRetryEAxisFault(Exception e){if( e instanceof ConnectException)return true;if( e instanceof AxisFault){AxisFault fault (AxisFault)e;if(fault.getFaultString().startsWith(java.net.ConnectException))return true;log.error( fault.dumpToString());return false;}return false;}//在log上显示错误 public static void showAxisFault(Exception e){ if( e instanceof AxisFault){AxisFault fault (AxisFault)e;log.error( fault.dumpToString());} }// 根据重复后退的retriesDelay参数在网络出现故障时进行重复。其中SoapUtils.ThrowingFunctionT, R func就是soap proxy中的具体某个方法。这个func因为抛出异常不能直接使用FunctionT,R需要通过ThrowingFunctionT,R extends FunctionT,R来实现。public static T, R R funcApplyWithThrow(SoapUtils.ThrowingFunctionT, R func,T param, Long ... retriesDelay) throws AxisFault,Exception{ if(retriesDelay ! null){for(int i 0 ; i retriesDelay.length ; i ){ try {return func.applyThrows(param);} catch (Exception e) { if(!SoapUtils.showAndCheckRetryEAxisFault(e))throw e;log.debug(Try to fix {}, resend({}) after {}ms, e.toString(), i1, retriesDelay[i]); } NormalUtils.sleep(retriesDelay[i]); }}try{return func.applyThrows(param);}catch(Exception e){SoapUtils.showAxisFault(e);throw e;} } //参考slieb.org/blog/throwable-interfaces/FunctionalInterfacepublic static interface ThrowingFunctionT,R extends FunctionT,R {Overridedefault R apply(T t){try{return applyThrows(t);}catch (RemoteException e){throw new RuntimeException(e);}}R applyThrows(T t) throws RemoteException;} } 具体某个重发的实现 private final MySoapProxy proxy new MySoapProxy(url);Override public QueryResponse query(Long ...retriesDelay) throws AxisFault,Exception{ QueryParam param new QueryParam();return SoapUtils.funcApplyWithThrow(proxy::query, param, retriesDelay); } 相关链接我的Professional Java for Web Applications相关文章
http://www.dnsts.com.cn/news/20465.html

相关文章:

  • 宝安建设网站用狐狸做logo的网站
  • 中国建设银行总行官方网站jsp电子商务网站建设实验
  • 重庆做网站泉州公司南宁百度seo排名价格
  • 金顶街网站建设西安做软件的公司
  • 科院公司网站建设目标是什么计算机大专学历有用吗
  • 桂林网站优化公司网站跟客户端推广怎么做
  • 国内做网站的龙头企业调用wordpress搜索代码
  • 广州网站建设大公司排名wordpress.html
  • 静态做网站河南省建设厅网站资质平移办法
  • vue做响应式网站我要表白网站
  • php网站后台忘记密码昌邑营销型网站建设
  • 网站备案ip地址wordpress摄影公司
  • 网站描述案例黄埔做网站的公司
  • 网站排队队列怎么做电脑公司网站模板
  • 哪个网站使用vue 做的录像网站怎么做
  • 网站设计平台大连建设网节能办公室网站
  • 两人合伙做网站但不准备开公司如何恢复wordpress
  • 网站改版是什么意思网站管理建设落实报告
  • 网站运营与管理实验报告个人做搜索引擎网站违法吗
  • wordpress带轮播企业站主题谷歌官方网站注册
  • 哪家房屋设计公司网站wordpress维基主题
  • 微金所网站谁做的网站建立的
  • 广州市建设工程检测中心网站在线培训课程
  • 网站中国风模板空间中国网站
  • 白云区做网站万网怎么做网站
  • 为什么使用html5网站房屋设计手机绘图软件
  • 网站seo检测工具专业网站建设经费申请报告
  • 免费做企业推广的网站网站后台模板论坛
  • 重庆网站制作套餐做网站如何分类
  • 网站自然优化网站 not found