一、xfire普通调用
1、需要引用如图的包
2、调用
public static String soapUrl = "http://192.168.1.66:9001/services/WebServiceSingleQuery?wsdl";
private static String userName = "query";
private static String passWord = "123456789";
String queryInfo = "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"yes\"?>"+
"<conditions>"+
"<condition queryType=\"xxxx\">"+
"<item>"+
"<name>name</name>"+
"<value>lvk618</value>"+
"</item>"+
"<item>"+
"<name>documentNo</name>"+
"<value>45092119910213xxxx</value>"+
"</item>"+
"<item>"+
"<name>subreportIDs</name>"+
"<value>xxxx</value>"+
"</item>"+
"<item>"+
"<name>refID</name>"+
"<value>2</value>"+
"</item>"+
"</condition>"+
"</conditions>";
Client client = new Client(new URL(soapUrl));
Object [] results = client.invoke("queryReport",new Object[]{userName,passWord,queryInfo,"xml"});
System.out.println("yyy=="+results[0]);
if(results[0] instanceof String){
//返回字符串,解析处理字符串内容
System.out.println("resut:"+results[0].toString());
}else if (results[0] instanceof org.w3c.dom.Document) {
//返回字符串Document,解析处理Document内容
org.w3c.dom.Document doc = (org.w3c.dom.Document)results[0];
Element element = doc.getDocumentElement();
NodeList children = element.getChildNodes();
Node node = children.item(0);
System.out.println("result content:"+node.getNodeValue());
}
二、xfire在ServiceMix中调用
1、所需要的ServiceMix下面的包
<span style="white-space:pre"> </span><dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.xfire</artifactId>
<version>1.2.6_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.wsdl4j</artifactId>
<version>1.6.3_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.jetty</artifactId>
<version>6.1.26_4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.jdom</artifactId>
<version>1.1.2_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.commons-httpclient</artifactId>
<version>3.1_7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.commons-codec</artifactId>
<version>1.3_2</version>
<scope>provided</scope>
</dependency>
2、调用
Client client = new Client(new URL(soapUrl));
Object [] results = client.invoke("queryReport",new Object[]{userName,passWord,queryInfo,"xml"});
System.out.println("yyy=="+results[0]);
if(results[0] instanceof String){
//返回字符串,解析处理字符串内容
System.out.println("resut:"+results[0].toString());
}else if (results[0] instanceof org.w3c.dom.Document) {
//返回字符串Document,解析处理Document内容
org.w3c.dom.Document doc = (org.w3c.dom.Document)results[0];
Element element = doc.getDocumentElement();
NodeList children = element.getChildNodes();
Node node = children.item(0);
System.out.println("result content:"+node.getNodeValue());
}