参考: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. 两表关联更新数据——oracle

    from testb b where b.id=a.id) ; (where exists(select 1 from testb b where b.id=a.id):如果没有这个条件,不匹配的选项 ...

  2. kafka 相关命令 偏移重置

    kafka官方文档 https://kafka.apache.org/documentation.html#quickstart kafka 安装文档 https://www.jianshu.com/ ...

  3. 使用Linux系统,是一种什么体验?

    导读 同事,从事嵌入式软件开发多年,主要开发环境用的就是linux,最疯狂的一段时间直接把系统装成linux系统,然后在linux下面虚拟一个windows操作系统,主要有些事情必须在windows才 ...

  4. HDU 5461:Largest Point

    Largest Point Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) To ...

  5. oracle提交commit后回退恢复

    -------------------------------------------------------begin---------------------------------------- ...

  6. EF Core的安装及入门

    一.环境准备 1.开发环境:.NET Core 3.1 2.IDE工具:Visual Studio 2019 3.数据库:SQL Server 2012 二.EF Core的安装 1.新建一个项目,如 ...

  7. MVC学生管理系统-阶段III(删除学生信息)

    项目源码 :https://download.csdn.net/download/weixin_44718300/11091042 前期准备,主体框架,学生列表显示  请看阶段一文章 添加学生信息   ...

  8. logrotate+crond日志切割、轮询

    logrotate 在工作中经常会有需求去查看日志,无论是通过应用或者系统error日志去查找问题或者通过nginx的访问日志统计站点日均PV.UV.所以体现了日志的重要性,但是通常当业务越来越大的时 ...

  9. Jenkins-在Centos上配置自动化部署(Jenkins+Gitlab+Rancher)

    Jenkins-在Centos上配置自动化部署(Jenkins+Gitlab+Rancher) 环境:centos7 首先在服务器上安装好Jenkins和Gitlab和Rancher Gitlab安装 ...

  10. zset底层数据结构

    redis zset底层数据结构 https://www.jianshu.com/p/fb7547369655 跳跃列表(Skip List)与其在Redis中的实现详解 https://www.ji ...