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

杭州网站建设网页制作商城项目

杭州网站建设网页制作,商城项目,wordpress做视频播放网站,如何申请免费空间使用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.hkea.cn/news/14305608/

相关文章:

  • 网站建设与网络营销珠海室内设计学校
  • 网站开发对算法有要求么互联网内容服务商有哪些
  • 网站设计的优点利用分类信息网站做推广
  • 龙采哈尔滨建站公司怎样做app
  • 免费模板网站知乎个人网站 icp 代理
  • 广州定制型网站建设大连企业信息
  • 做恋爱方面的网站外贸流程图片
  • 网站素材模板个人型网站开站费用
  • 学习吧网站网站主色调简介
  • 建设网站松岗做微信平台图片网站
  • 织梦源码网站模板网站设计方案怎么做
  • 做检索网站如何建淘客网站
  • 网页美工制作网站网站验证码原理
  • 在网上做效果图赚钱的网站如今做哪些网站能致富
  • 帝国网站地图模板邯郸哪做网站
  • 如何快速优化网站排名网站的目的和意义
  • 绵阳网站建设软件有哪些西安做视频网站公司
  • 做网站准备的资料北京网站建设工作室哪家好
  • 网站一键生成手机网站特价锦州网站建设
  • 摄影婚纱网站建设网站快捷按钮以什么方式做
  • 专门找人做软件的网站扬州做网站
  • 做英语趣味教具的网站网站服务器申请
  • 深圳网站设计哪家强个人博客自我介绍
  • 衡阳网站建设公司哪家好电脑可以做网站主机么
  • 网站项目建设策划书搜索百度
  • 湖南微信网站公司电话教师兼职做网站
  • 万江专业网站快速排名无锡百度seo优化
  • 有服务器和域名怎么做网站wordpress nextpage
  • 上海企业网站模板建站平台平面设计和电商设计的区别
  • 怎么做二维码进入公司网站数据库网站 建设