利用axis调用webservice接口

一.首先把wsdl文件放入eclipse中某个项目中的src目录下

二.右键弹出webservice,然后点击webservice菜单,选中genernator client ,选择axis生成Java文件

三,然后调用.

调用说明(其中一种的调用方式):

DHSFServiceLocator service = new DHSFServiceLocator();
  service.setDH_spcSF_spcIntegration_spcServiceWSDDServiceName("AccountCreate");
  URL url;
  String accountCode="";
  String JsonData = "{"accountName":"D15422312","accountID":"0010k00000PtIXV","accountSource":"DP","customerProperty":"OEM","region":"Europe","country":"GB","province":"Leicester","
    + ""city":"Leicester","address":"BUDAN STREET","owner":"13578","industry":"Transportation","accountType":"Distributor","purchaseTotal":"1000","description":"test","busCountry":"GB","marketScope":"GB;AU","AccountCode":"","RegistrationNumber":"2356123","OverseaDegree":"S", "BusEntry":"Dahua Hongkong; Dahua technology", "BringReason" :"Leadcovert","ClientTradeNames1":"test1","ClientTradeNames2":"test2","ValueOEM":"Strategy Guide", "DegreeOEM":"Depth","PurchaseTotalBrand":"","+
    ""PurchaseTotalOEM":"2345","Sharer":"24815;29480","UpdateType":"0","ChangeID":"","AccountLanguage":"","accountStatus":"0","AttachmentURL":"www.baidu.com"}";
  JSONObject jsonObject =JSONObject.fromObject(JsonData);
  
  StringHolder error_spcCode = new StringHolder("");
  StringHolder error_spcMessage = new StringHolder("");
  
  String accountName = jsonObject.getString("accountName");
  String sFAccountId = jsonObject.getString("accountID");
  String accountSource = jsonObject.getString("accountSource");
  String customerProperty = jsonObject.getString("customerProperty");
  String region = jsonObject.getString("region");
  String country = jsonObject.getString("country");
  String province = jsonObject.getString("province");
  String city = jsonObject.getString("city");
  String address = jsonObject.getString("address");
  String owner = jsonObject.getString("owner");
  String industry = jsonObject.getString("industry");
  String accountType = jsonObject.getString("accountType");
  String purchaseTotal = jsonObject.getString("purchaseTotal");
  String description = jsonObject.getString("description");
  String busCountry = jsonObject.getString("busCountry");
  String marketScope = jsonObject.getString("marketScope");
  String AccountCode=jsonObject.getString("AccountCode");
  String RegistrationNumber=jsonObject.getString("RegistrationNumber");
  String OverseaDegree=jsonObject.getString("OverseaDegree");
  String BusEntry=jsonObject.getString("BusEntry");
  String BringReason=jsonObject.getString("BringReason");
  String ClientTradeNames1=jsonObject.getString("ClientTradeNames1");
  String ClientTradeNames2=jsonObject.getString("ClientTradeNames2");
  String ValueOEM=jsonObject.getString("ValueOEM");
  String DegreeOEM=jsonObject.getString("DegreeOEM");
  String PurchaseTotalBrand=jsonObject.getString("PurchaseTotalBrand");
  String PurchaseTotalOEM=jsonObject.getString("PurchaseTotalOEM");
  String Sharer=jsonObject.getString("Sharer");
  String UpdateType=jsonObject.getString("UpdateType");
  String ChangeID=jsonObject.getString("ChangeID");
  String AccountLanguage=jsonObject.getString("AccountLanguage");//客户语言
  String accountStatus=jsonObject.getString("accountStatus");//客户状态
  String AttachmentURL=jsonObject.getString("AttachmentURL");//客户附件
  
  try {
   //wsdl中的服务地址.(wsdl文件)
   url = new URL("http://10.1.1.204:7777/eai_chs/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&Username=SADMIN&Password=Cde32wsx");
   DH_spcSF_spcIntegration_spcServiceStub stub = new DH_spcSF_spcIntegration_spcServiceStub(url,service);
//调用对象中的方法
   accountCode=stub.accountCreate(accountName, sFAccountId, accountSource,customerProperty, region, country, province, city,address, owner, industry, accountType, purchaseTotal, description,  busCountry, marketScope,AccountCode,RegistrationNumber,OverseaDegree,BusEntry,BringReason,ClientTradeNames1,ClientTradeNames2,ValueOEM,DegreeOEM,PurchaseTotalBrand,PurchaseTotalOEM,Sharer,UpdateType,ChangeID,AccountLanguage,accountStatus,AttachmentURL,error_spcCode, error_spcMessage);
      if(null==accountCode||"".equals(accountCode)){
       error_spcCode.value = "fail";
      }else{
       error_spcCode.value = "OK";
      }
  } catch (MalformedURLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   error_spcMessage.value = e.getMessage();
  }catch (AxisFault e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   error_spcCode.value = "AxisFault";
   error_spcMessage.value = e.getMessage();
  } catch (RemoteException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   error_spcCode.value = "RemoteException";
   error_spcMessage.value = e.getMessage();
  }
  
  System.out.println(accountCode);
  System.out.println(error_spcCode.value);
  System.out.println(error_spcMessage.value);
 
 
利用axis调用webservice接口

利用axis调用webservice接口

  accountCreate方法:传参数值过来  ,_call.invoke(new Object[]{"多个参数"}),如传多个参数,那么就需要用到_call.setOperation(_operations[2]);设置参数,要跟参数值的名字对应得上

利用axis调用webservice接口

利用axis调用webservice接口

利用axis调用webservice接口

利用axis调用webservice接口

利用axis调用webservice接口