OSGI系列 xfire调用WebService

一、xfire普通调用

1、需要引用如图的包



2、调用

public static String soapUrl = "http://192.168.1.66:9001/services/WebServiceSingleQuery?wsdl";
    private static String userName = "query";
    private static String passWord = "123456789";

String queryInfo = "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"yes\"?>"+
     "<conditions>"+
        "<condition queryType=\"xxxx\">"+
            "<item>"+
                "<name>name</name>"+
                "<value>lvk618</value>"+
            "</item>"+
            "<item>"+
                "<name>documentNo</name>"+
                "<value>45092119910213xxxx</value>"+
            "</item>"+
            "<item>"+
                "<name>subreportIDs</name>"+
                "<value>xxxx</value>"+
            "</item>"+
            "<item>"+
                "<name>refID</name>"+
                "<value>2</value>"+
            "</item>"+
        "</condition>"+
    "</conditions>";

Client client = new Client(new URL(soapUrl));
    Object [] results = client.invoke("queryReport",new Object[]{userName,passWord,queryInfo,"xml"});

    System.out.println("yyy=="+results[0]);
    if(results[0] instanceof String){
        //返回字符串,解析处理字符串内容 
        System.out.println("resut:"+results[0].toString());
    }else if (results[0] instanceof org.w3c.dom.Document) {
       //返回字符串Document,解析处理Document内容
        org.w3c.dom.Document doc = (org.w3c.dom.Document)results[0];

       Element element = doc.getDocumentElement();
       NodeList children = element.getChildNodes();
       Node node = children.item(0);
       System.out.println("result content:"+node.getNodeValue());
}

二、xfire在ServiceMix中调用

1、所需要的ServiceMix下面的包

<span style="white-space:pre">	</span><dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.xfire</artifactId>
            <version>1.2.6_1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.wsdl4j</artifactId>
            <version>1.6.3_1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.jetty</artifactId>
            <version>6.1.26_4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.jdom</artifactId>
            <version>1.1.2_1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.commons-httpclient</artifactId>
            <version>3.1_7</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.commons-codec</artifactId>
            <version>1.3_2</version>
            <scope>provided</scope>
        </dependency>

2、调用

Client client = new Client(new URL(soapUrl));
    Object [] results = client.invoke("queryReport",new Object[]{userName,passWord,queryInfo,"xml"});

    System.out.println("yyy=="+results[0]);
    if(results[0] instanceof String){
        //返回字符串,解析处理字符串内容 
        System.out.println("resut:"+results[0].toString());
    }else if (results[0] instanceof org.w3c.dom.Document) {
       //返回字符串Document,解析处理Document内容
        org.w3c.dom.Document doc = (org.w3c.dom.Document)results[0];

       Element element = doc.getDocumentElement();
       NodeList children = element.getChildNodes();
       Node node = children.item(0);
       System.out.println("result content:"+node.getNodeValue());
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值