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

php怎么做网站后台移动端网站建设

php怎么做网站后台,移动端网站建设,浏览器免费大全,网站建设维护多少钱使用Eclipse自动生成Soap Client的代码 在项目按右键,选择New -> Other ->Web Services -> Web Service Client,进入向导。 加入自有代码,例如加入Envelope Header 在xxxxStub.java文件相应的方法中加入: 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.ThrowingFunction<T, R> func就是soap proxy中的具体某个方法。这个func因为抛出异常,不能直接使用Function<T,R>,需要通过ThrowingFunction<T,R> extends Function<T,R>来实现。public static <T, R> R funcApplyWithThrow(SoapUtils.ThrowingFunction<T, 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(), i+1, 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 ThrowingFunction<T,R> extends Function<T,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.yayakq.cn/news/450359/

相关文章:

  • 模板网点地址信息获取错误是什么意思揭阳百度seo公司
  • 国外网站 设计公司网站推广技巧
  • 商城手机网站建设编辑wordpress模板下载
  • 如何建立网站站点wordpress html5音乐播放器
  • 基于jsp的电子商务网站开发怎么看一个网站是否是外包做的
  • 谢家华做网站免费推广途径
  • 山东学生做自我评价的网站wordpress termmeta
  • 泰拳图片做网站用清远网站开发sohu
  • 磁力搜索引擎torrentkitty网站如何优化流程
  • 苏州建站推广定制营销型网站设计难不难
  • 深圳外贸soho网站建设丝网外贸做哪些网站
  • 旅游品牌网站的建设wordpress academy
  • 自己做的网站怎么放视频教程erp系统的功能包括哪些
  • 网站开发人员应该用什么浏览器企业网站最底下做的是什么
  • 网站架构怎么看wordpress和discuz织梦
  • 铁岭 网站建设崇信门户网站留言回复
  • 博达站群网站建设教程it行业是什么工作 做什么的
  • 自助网站开发泽州县住房保障和城乡建设局网站
  • 设计优秀的企业网站展示产品的网站 个人备案还是企业
  • 网站改版 删除栏目网站的域名不能登录
  • 分析网站网站网站空间购买费用
  • 个人网站的建设流程wordpress预加载插件
  • 网站怎么seo北海哪家公司做网站建设研发
  • 长春网站优化团队wordpress主题 插件下载
  • 个人做 下载类网站一般建设一个网站多少钱
  • 温州手机网站制作哪家好网易企业邮箱收费版
  • 白之家 低成本做网站宣传设计网站
  • 闵行网站建设外包武威市凉州区建设局网站
  • 中山营销型网站建设做a短视频网站
  • 腾讯人脸认证网站建设360免费wifi怎么安装