zoukankan      html  css  js  c++  java
  • 使用axis2访问webservice(webserivice基于.net平台实现)

    webservice url=http://10.90.11.240:8081/ExceptionWebService.asmx?WSDL;

    下载axis2组件,解压,进入bin目录,通过命令wsdl2java -uri http://10.90.11.240:8081/ExceptionWebService.asmx?WSDL -p com.zsp.proxy -s -o source

    -uri 后面运行的是 你的wsdl地址, -p 是文件生成的包名 -o source生成的文件目录,在bin目录下。

    把生成的代理类,拷贝到你的工程目录中,导入对应的包即可访问:

    例如

    POST /ExceptionWebService.asmx HTTP/1.1
    Host: 10.90.11.240
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://tempuri.org/ApproveException"
    
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <ApproveException xmlns="http://tempuri.org/">
          <eventName>string</eventName>
          <description>string</description>
          <occurTime>string</occurTime>
          <livingPlace>string</livingPlace>
          <eventLevel>一般 or 急件 or 紧急 or 特急</eventLevel>
          <bussinessCategory>运销 or 管道 or 设备 or HSE or 经营 or 管理 or 工程 or 科技 or 信息 or 党群 or 其它</bussinessCategory>
          <reporterId>string</reporterId>
          <contact>string</contact>
          <systemId>string</systemId>
          <businessPK>string</businessPK>
          <remark>string</remark>
          <isRelease>boolean</isRelease>
          <measures>string</measures>
        </ApproveException>
      </soap:Body>
    </soap:Envelope>

    访问时:

    public class Test2 {
    
        public static void main(String[] args) throws RemoteException {
            // TODO Auto-generated method stub
            ExceptionServiceStub proxy = new ExceptionServiceStub();
    
            ExceptionServiceStub.ApproveException exp = new ExceptionServiceStub.ApproveException();
            exp.setContact("374378");
            exp.setDescription("描述");
            exp.setEventName("测试异常");
            exp.setIsRelease(true);
            exp.setLivingPlace("发生地点");
            exp.setMeasures("47477474");
            exp.setOccurTime("2019-09-09");
            exp.setSystemId("xj_001");
            exp.setRemark("备注");
            exp.setEventLevel(EmergencyDegree.一般);
            exp.setBussinessCategory(BusinessCategory.HSE);
            exp.setBusinessPK("bpk");
            exp.setReporterId("xxxx");
            ApproveExceptionResponse res = proxy.approveException(exp);
            System.out.println(res.getApproveExceptionResult());
        }
    
    }

    使用内部类的方式设置参数,很方便,这种方式和C#通过VS生成代理的操作方式基本一致。

    客户端需要导入的包如下:

  • 相关阅读:
    [LeetCode]2. Add Two Numbers链表相加
    Integration between Dynamics 365 and Dynamics 365 Finance and Operation
    向视图列添加自定义图标和提示信息 -- PowerApps / Dynamics365
    Update the Power Apps portals solution
    Migrate portal configuration
    Use variable to setup related components visible
    Loyalty management on Retail of Dynamic 365
    Modern Fluent UI controls in Power Apps
    Change screen size and orientation of a canvas app in Power App
    Communication Plan for Power Platform
  • 原文地址:https://www.cnblogs.com/Johnzhang/p/4870915.html
Copyright © 2011-2022 走看看