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

基于Axis 1.4 部署WebService 笔记三

上面2章我们WebService已经可以正常发布了。现在我们来写服务器端和客户端代码

我们用Aixs生成java code里有个SyncNotifySPSoapBindingImpl类,这个就是写服务器端代码入口,如果你用wsdl不一样那应该是***Impl.java 这样规则的文件

 

贴出我的服务器端代码

public class SyncNotifySPSoapBindingImpl implements com.unicom.vac.bossagent.soap.SyncNotifySPService{


    public com.unicom.vac.bossagent.soap.sync.rsp.OrderRelationUpdateNotifyResponse orderRelationUpdateNotify(com.unicom.vac.bossagent.soap.sync.req.OrderRelationUpdateNotifyRequest orderRelationUpdateNotifyRequest) throws java.rmi.remoteexception {


     System.out.println("已调用");
     OrderRelationUpdateNotifyResponse response=new OrderRelationUpdateNotifyResponse();
     response.setRecordSequenceId("1");
     response.setResultCode(1);
     return response;


    }

 

}

贴出我客户端代码

public class WebServiceClient {

 

 private SyncNotifySPServiceServiceLocator locator=null;
 private SyncNotifySPServiceService serviceService=null;
 private OrderRelationUpdateNotifyResponse response=null;
 public com.unicom.vac.bossagent.soap.sync.rsp.OrderRelationUpdateNotifyResponse setRequest(){


  try{


  OrderRelationUpdateNotifyRequest orunr=new OrderRelationUpdateNotifyRequest();
  locator=new SyncNotifySPServiceServiceLocator();
  locator.setEndpointAddress("SyncNotifySP","http://localhost:8080/VacSyncService/services/SyncNotifySP");
  serviceService=locator;
  SyncNotifySPService ser=serviceService.getSyncNotifySP();
  orunr.setContent("1");
  orunr.setEffectiveDate("2");
  orunr.setEncodeStr("3");
  orunr.setExpireDate("4");
  orunr.setLinkId("5");
  orunr.setProductId("6");
  orunr.setRecordSequenceId("7");
  orunr.setServiceType("8");
  orunr.setSpId("9");
  orunr.setTime_stamp("10");
  orunr.setUpdateTime("11");
  orunr.setUpdateDesc("12");
  orunr.setUpdateType(13);
  orunr.setUserId("14");
  orunr.setUserIdType(15);
  response=ser.orderRelationUpdateNotify(orunr);
  if(response!=null){
   System.out.println(response.getRecordSequenceId());
  }else{
   System.out.println("response is null!");
  }
  

}catch(Exception ex){


   ex.printstacktrace();

  }
  return response;
  
 }
 /**
  * @param args
  */
 public static void main(String[] args) {
  // Todo Auto-generated method stub
  WebServiceClient wc=new WebServiceClient();
  wc.setRequest();
 }

}

 

 

WebService的学习就先介绍到这里。我测试客户端代码调用服务器端代码没有问题。这个例子只做学习之用。

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

相关推荐