参考:http://aperise.iteye.com/blog/2223454

     http://blog.csdn.net/chenleixing/article/details/43456987

 package explore;

 import java.io.IOException;
import java.nio.charset.Charset; import org.apache.commons.lang.StringEscapeUtils;
import org.apache.http.HttpEntity;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils; import util.IOUtil; public class HttpClientWay1 { static int socketTimeout = 30000;// 请求超时时间
static int connectTimeout = 30000;// 传输超时时间 public static void main(String[] args) {
try {
// wsdl
// http://fw1test.shdzfp.com:7500/axis2/services/SajtIssueInvoiceService
String con; // 组织推送报文
// con = GenerateXml.shift_plus("pt_kpttxx.xml");
con = IOUtil.msgMachine("my.xml");
System.out.println(con); // 创建HttpClientBuilder
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// HttpClient
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
HttpPost httpPost = new HttpPost("http://fw1test.shdzfp.com:7500/axis2/services/SajtIssueInvoiceService"); // 设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(socketTimeout)
.setConnectTimeout(connectTimeout).build();
httpPost.setConfig(requestConfig); httpPost.setHeader("Content-Type", "text/xml;charset=UTF-8");
httpPost.setHeader("SOAPAction", "");
StringEntity data = new StringEntity(con, Charset.forName("UTF-8"));
httpPost.setEntity(data);
CloseableHttpResponse response = closeableHttpClient.execute(httpPost);
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
// 打印响应内容
String retStr = EntityUtils.toString(httpEntity, "UTF-8");
retStr = StringEscapeUtils.unescapeXml(retStr);// 反转义
System.out.println(retStr);
}
// 释放资源
closeableHttpClient.close();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

附 wsdl 内容:

 This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://service.sl.shdzfp.sajt" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://service.sl.shdzfp.sajt">
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.sl.shdzfp.sajt">
<xs:element name="eiInterface">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="in0" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="eiInterfaceResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="eiInterfaceRequest">
<wsdl:part name="parameters" element="ns:eiInterface"></wsdl:part>
</wsdl:message>
<wsdl:message name="eiInterfaceResponse">
<wsdl:part name="parameters" element="ns:eiInterfaceResponse"></wsdl:part>
</wsdl:message>
<wsdl:portType name="SajtIssueInvoiceServicePortType">
<wsdl:operation name="eiInterface">
<wsdl:input message="ns:eiInterfaceRequest" wsaw:Action="urn:eiInterface"></wsdl:input>
<wsdl:output message="ns:eiInterfaceResponse" wsaw:Action="urn:eiInterfaceResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SajtIssueInvoiceServiceSoap11Binding" type="ns:SajtIssueInvoiceServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="eiInterface">
<soap:operation soapAction="urn:eiInterface" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="SajtIssueInvoiceServiceSoap12Binding" type="ns:SajtIssueInvoiceServicePortType">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="eiInterface">
<soap12:operation soapAction="urn:eiInterface" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="SajtIssueInvoiceServiceHttpBinding" type="ns:SajtIssueInvoiceServicePortType">
<http:binding verb="POST"/>
<wsdl:operation name="eiInterface">
<http:operation location="SajtIssueInvoiceService/eiInterface"/>
<wsdl:input>
<mime:content part="eiInterface" type="text/xml"/>
</wsdl:input>
<wsdl:output>
<mime:content part="eiInterface" type="text/xml"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SajtIssueInvoiceService">
<wsdl:port name="SajtIssueInvoiceServiceHttpSoap11Endpoint" binding="ns:SajtIssueInvoiceServiceSoap11Binding">
<soap:address location="http://fw1test.shdzfp.com:7500/axis2/services/SajtIssueInvoiceService.SajtIssueInvoiceServiceHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="SajtIssueInvoiceServiceHttpEndpoint" binding="ns:SajtIssueInvoiceServiceHttpBinding">
<http:address location="http://fw1test.shdzfp.com:7500/axis2/services/SajtIssueInvoiceService.SajtIssueInvoiceServiceHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

JavaEE--调用 WSDL -- httpclient 4.x.x的更多相关文章

  1. C# 不添加WEB引用调用WSDL接口

    在项目中添加WEB引用耦合度较高,更新时要更新引用,所以我建议不添加WEB引用调用WSDL接口,废话不多说,直接上代码 例如WSDL地址为:http://XXX.XX.XXX.XXX:9115/WsP ...

  2. php7-soap调用wsdl接口报错:Could not connect to host

    由php5.6升级到php7.1以上版本,在用soap调用wsdl接口是报错:Could not connect to host 后来经过排查是centos服务器上装有2个版本的openssl造成的. ...

  3. axis2调用WSDL接口

    public static JSONObject sendWsdl(String url,String xmlStr){ JSONObject res=new JSONObject(); try { ...

  4. 采用WebService客户端调用WSDL/SOAP网络报错的解决办法

    WebService接口是网络传输控制的重要途径,在Windows系统下运行客户端时,平时一直能正确运行,但某天可能突然会发生调用wsdl soap邮件标头无法识别等莫名其妙的错误提示,出现这种情况一 ...

  5. C#/Java 调用WSDL接口及方法

    一.C#利用vs里面自带的“添加web引用”功能: 1.首先需要清楚WSDL的引用地址  如:http://www.webxml.com.cn/Webservices/WeatherWebServic ...

  6. java 调用wsdl的webservice接口 两种调用方式

    关于wsdl接口对于我来说是比较头疼的 基本没搞过.一脸懵 就在网上搜 看着写的都很好到我这就不好使了,非常蓝瘦.谨以此随笔纪念我这半个月踩过的坑... 背景:短短两周除了普通开发外我就接到了两个we ...

  7. cxf动态调用wsdl的一个冲突以及解决

    cxf发布服务,调用服务的博客很多,这里也就简单贴一下代代码. 环境如下:spring+cxf (maven环境) <cxf.version>2.7.11</cxf.version& ...

  8. http调用端HttpClient、DefaultHttpClient、CloseableHttpClient

    1:说下httpClient接口和4.2.6版本后过时实例DefaultHttpClient,以及新的实例应用.  说到HTTP,脑子就冒出它的特性,基于TCP协议,简短点:说明是交互性的. 2:下面 ...

  9. java-webService(调用wsdl接口)

    使用Axis或XFire实现WebService: Axis2是Apache下的一个重量级WebService框架,准确说它是一个Web Services / SOAP / WSDL 的引擎,是Web ...

  10. C#.NET调用WSDL接口及方法

    1.首先需要清楚WSDL的引用地址 如:http://XX.XX.4.146:8089/axis/services/getfileno?wsdl 上述地址的构造为 类名getfileno. 2.在.N ...

随机推荐

  1. 学习EIGRP 笔记

    CEFFIB(转发信息库,RIB现在运行了CEF,就称之为FIB)show ip cef detail EIGRP的基本组件:1.邻居发现机制2.可靠传输协议(RTP机制)3.DUAL算法4.多种网络 ...

  2. SPOJ - AMR11H Array Diversity (排列组合)

    题意:给定n个数,求包含最大值和最小值的子集(数字连续)和子序列(数字不连续)的个数. 分析: 1.如果n个数都相同,则子集个数为N * (N + 1) / 2,子序列个数为2N-1. 2.将序列从头 ...

  3. Kubernetes-基于helm安装部署高可用的Redis及其形态探索

    首先是一些关于redis的介绍和其在K8S上的安装过程:https://www.kubernetes.org.cn/3974.html 1.1部署形态 通过上述地址的教程,可以完成redis 的安装和 ...

  4. JQ+AJAX 发送异步请求

    1. load() ; 作用:通过ajax 请求从服务器加载数据,并添加到符合要求的节点上 用法:$node.load(请求地址,请求参数) 请求参数写法: --"username=admi ...

  5. 自定义checkbox,redio等

    直接上代码: 看的懂看,看不懂拉到. .messageState li {list-style: none;float: left;padding-right:30px;font-size: 16px ...

  6. 63.Python中contains和icontains

    1. contains: 进行大小写敏感的判断,某个字符串是否包含在指定的字段中,这个判断条件使用大小写敏感进行判断,因此在被翻译成"SQL"语句的时候,会使用"like ...

  7. 吴裕雄--天生自然TensorFlow2教程:数据加载

    import tensorflow as tf from tensorflow import keras # train: 60k | test: 10k (x, y), (x_test, y_tes ...

  8. 使用Spring Data Mongodb的MongoRepository类进行增删改查

    Spring Data Mongodb提供一套快捷操作 mongodb的方法,创建Dao,继承MongoRepository,并指定实体类型和主键类型. public interface CmsPag ...

  9. Codeforces 1296C - Yet Another Walking Robot

    题目大意: 给定一个机器人的行走方式 你需要取走一段区间 但要保证取走这段区间后机器人最终到达的终点位置是不变的 问这段区间最短时是哪一段 解题思路: 易得,如果重复走到了某些已经走过的点,那么肯定就 ...

  10. 读取word模板,填充数据后导出

    一.需求说明 定期生成word报告,报告中含有文本.表格.图表等元素,依次获取进行替换,保留原有样式,生成新的word文档 二.引入依赖 <dependency> <groupId& ...