Axis调用webservice

Axis调用webservice

import com.google.gson.Gson;
import org.apache.axis.client.Call;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
public class SoapUtils {

private static Logger logger = LoggerFactory.getLogger(PostJsonUtil.class);
public Map<String,Object> map = new HashMap<String,Object>();

public static String  doSoap(String invokUrl, ConditonDto conditonDto) {
    //拼接参数
    String method = "pushWbData";
    String soapResponseData = "";
    StringBuffer stringBuffer = new StringBuffer();
    Gson gson = new Gson();
    String sttr = gson.toJson(conditonDto);
    
    /*WbHlwWebservice wbHlwWebservice= new WbHlwWebservice();
    com.t3.ts.guangzhou.standard.data.webservice.WbHlwWebservicePortType WbHlwWebservicePortType =wbHlwWebservice.getWbHlwWebserviceHttpPort();
    
    String rest =WbHlwWebservicePortType.pushWbData(sttr);
    return "0";//rest;*/
    String result = "";
    Service service = new Service();
    try {
        Call call = (Call) service.createCall();
        call.setTargetEndpointAddress(invokUrl);
        call.setEncodingStyle("utf-8");
        call.addParameter("condition", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
        call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
        call.setOperationName(new QName(invokUrl,method));
        result = (String) call.invoke(new Object[]{sttr});
        System.out.println("返回值:" + result);
    } catch (Exception e) {
        System.out.print("WebService请求异常!! ");
        e.printStackTrace();
    }
    return result;
}

}
pom依赖

    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>commons-discovery</groupId>
        <artifactId>commons-discovery</artifactId>
        <version>0.2</version>
        <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis-jaxrpc</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis-saaj</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>wsdl4j</groupId>
        <artifactId>wsdl4j</artifactId>
        <version>1.4</version>
    </dependency>

注意:url地址后面?wsdl去掉

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值