方法一:
采用cxf的方式
JaxWsDynamicClientFactory qz_dcf =JaxWsDynamicClientFactory.newInstance();
//qz_url指的是wsdl路径
Client qz_client =qz_dcf.createClient(qz_url);
//eiInterface 方法名 QzXml xml报文
Object[] qz_objects=qz_client.invoke("eiInterface",QzXml);
log.info(qz_objects[0].toString());
方法二
采用httpclient post的方法
//qz_url指的是wsdl路径
PostMethod post = new PostMethod(qz_url);
post.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
//QzXml xml报文 这里的报文要加SoapUIS的头部和尾部
logger.info("接口发送内容为:" + QzXml);
RequestEntity requestEntity = new StringRequestEntity(QzXml);
post.setRequestEntity(requestEntity);
HttpClient httpClient = new HttpClient();
state = httpClient.executeMethod(post);
//头部大小已经处理用下边这句也行
//String responseBody = new String(post.getResponseBodyAsString());
//预防头部没有设置大小的语句
BufferedReader reader = new BufferedReader(new InputStreamReader(post.getResponseBodyAsStream()));
StringBuffer stringBuffer = new StringBuffer();
String str = "";
while((str = reader.readLine())!=null){
stringBuffer.append(str);
}
String ts = stringBuffer.toString();
System.out.println(ts);