微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

xfire 做webservice总结

最近在一个项目中用了webservice做两个系统传输数据,对应数据传输的只是javabean。

一。先创建一个传输的javabean

public class AtsEventIncident implements java.io.Serializable {

 // Fields

 /**
  *
  */
 private static final long serialVersionUID = 8517650101550991383L;  //记得这个序列,如果不加这个就会出现传输的对象有问题



 private String belongSystem;

 private Date needResolveTime;

 private String oldBillNo;

 private String presenter;

。。。。。。

二。建立传输接口

public interface IAlertService {
  public String  sendItil(AtsEventIncident incident);
}

三。实现类,在实现类中用到了IIncidentService ,MwFormDao 。

public class AlertServiceImpl implements IAlertService{
 IIncidentService serv;
 MwFormDao dao;
 commonForm form;
  public String  sendItil(AtsEventIncident ats){
  //String urlStr="http://192.168.129.87:8089/itil/";
   String urlStr =form.getUrlstr()+"&id=";
     Incident incident=new Incident();
     getIncidentData(ats,incident);
     try {
   serv.createalarmIncident(incident,"");
    urlStr=urlStr+incident.getId()+","+incident.getBillNo();
      System.out.println("urlStr--->"+urlStr);
   } catch (Exception e) {
    // Todo: handle exception
   }
  return urlStr;
  
  }

三。新建一个services.xml,对应的目录是 src/xfire/meta-inf/xfire

四。在spring配置文件中配置

<bean id="BbtForumService"  class="org.codehaus.xfire.spring.remoting.XFireExporter">  <property name="serviceFactory" ref="xfire.serviceFactory" />  <property name="xfire" ref="xfire" />  <property name="serviceBean" ref="alertServiceImpl" />  <property name="serviceClass"   value="com.thbs.interact.webService.IAlertService" />  <property name="name" value="IncidentService" /> </bean> <bean id="alertServiceImpl"  class="com.thbs.interact.webService.impl.AlertServiceImpl">  <property name="dao" ref="mwFormDao" />  <property name="serv" ref="incidentService" />  <property name="form" ref="commonForm" /> </bean>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐