|
|
|
@ -8,6 +8,7 @@ import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import javax.xml.namespace.QName;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
|
@ -21,22 +22,23 @@ public class JaxWsDynamicClient {
|
|
|
|
|
private static final Map<String, Client> CLIENT_MAP=new ConcurrentHashMap<>();
|
|
|
|
|
private static final Logger logger= LoggerFactory.getLogger(JaxWsDynamicClient.class);
|
|
|
|
|
|
|
|
|
|
public static String send(String wsdlUrl,String namespaceUri,String operationName,Object param){
|
|
|
|
|
public static String send(String wsdlUrl,String namespaceUri,String operationName,Object[] params){
|
|
|
|
|
logger.debug("wsdlUrl:" + wsdlUrl +"namespaceUri: "+namespaceUri+ " ,operationName:" + operationName + ",param:" + Arrays.toString(params));
|
|
|
|
|
try {
|
|
|
|
|
Client client = getClient(wsdlUrl);
|
|
|
|
|
Object[] result;
|
|
|
|
|
if (namespaceUri == null || namespaceUri.isEmpty()) {
|
|
|
|
|
result = client.invoke(operationName, param);
|
|
|
|
|
result = client.invoke(operationName, params);
|
|
|
|
|
} else {
|
|
|
|
|
QName qName = new QName(namespaceUri, operationName);
|
|
|
|
|
result = client.invoke(qName, param);
|
|
|
|
|
result = client.invoke(qName, params);
|
|
|
|
|
}
|
|
|
|
|
if (result == null || result[0] == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return String.valueOf(result[0]);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
logger.error("wsdlUrl:" + wsdlUrl + " ,operationName:" + operationName + ",param:" + param + " 调用失败了!", ex);
|
|
|
|
|
logger.error("wsdlUrl:" + wsdlUrl +"namespaceUri: "+namespaceUri+ " ,operationName:" + operationName + ",param:" + Arrays.toString(params)+" 调用失败了!", ex);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -59,14 +61,7 @@ public class JaxWsDynamicClient {
|
|
|
|
|
httpClientPolicy.setConnectionTimeout(30000);
|
|
|
|
|
httpClientPolicy.setAllowChunking(false);
|
|
|
|
|
httpClientPolicy.setReceiveTimeout(30000);
|
|
|
|
|
|
|
|
|
|
HTTPConduit clientConduit = (HTTPConduit) client.getConduit();
|
|
|
|
|
clientConduit.setClient(httpClientPolicy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
String[] param={"111"};
|
|
|
|
|
System.out.println(send("http://127.0.0.1:9311/webservice/api?wsdl","http://impl.webservice.collection.server.docus.com/", "pushUpdateInspectionReport", param));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|