参考: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. 说说lock到底要锁谁?

    波安搬... http://www.cnblogs.com/wolf-sun/p/4209521.html ---------------------------------------------- ...

  2. mybatis中实体类跟数据库属性不一致解决方案

    1.在Mapper.xml映射配置文件中给sql语句起别名 select id as uid,username as name from user 2.mybatis中可以单独的配置查询结果的列名和实 ...

  3. C++ STD Gems04

    count.count_if.all_of.any_of.none_of #include <iostream> #include <vector> #include < ...

  4. 64.Python中ORM查询条件:in和关联模型

    定义模型的models.py文件中示例代码如下: from django.db import models class Category(models.Model): name = models.Ch ...

  5. 十七、CI框架之数据库操作insert用法

    一.代码如下: 二.我们访问一下页面 三.查看数据库,已经插入了一条数据 不忘初心,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢.

  6. JS高级学习笔记(10) 之 js 时怎么解析HTML标签的

    DOM 节点类型 浏览器渲染过程 浏览器是怎么把HTML标签语言和JavaScript联系在一起的,这就是我们常说的DOM. 浏览器中的DOM解析器把HTML翻译成对象(object),然后JavaS ...

  7. LeJOS下eclipse通过USB连接EV3

    适用情况:在eclipse安装好LeJOS插件后,再通过USB连接EV3. 第一:更新驱动 在<设备管理器-网络适配器>下更新RNDIS/Ethernet Gadget,电脑需要先连接EV ...

  8. 基于磁盘的Kafka为什么这么快

    专注于Java领域优质技术,欢迎关注 作者: Wyman 大数据手稿笔记 Kafka是大数据领域无处不在的消息中间件,目前广泛使用在企业内部的实时数据管道,并帮助企业构建自己的流计算应用程序.Kafk ...

  9. java获取配置文件信息

    两个类 package com.censoft.util; import java.util.Properties; import java.io.*; import java.util.ArrayL ...

  10. SSM框架和微服务构架和的联系与区别

    spring和springMvc: 1. spring是一个一站式的轻量级的java开发框架,核心是控制反转(IOC)和面向切面(AOP),针对于开发的WEB层(springMvc).业务层(Ioc) ...