[java]代码库
/**
* AXIS 调用 .NET开发的wbservice接口
* @param endPointAddr webservice接口路径
* @param nameSpace nameSpace 就是你用浏览器打开WSURl路径加上?wsdl,即http://xxx/SendWebService.asmx?wsdl 中的targetNamespace属性值
* @param method 调用的方法名
* @param params 参数名称数组
* @param values 参数值数组
* @return
*/
public static Map axisEndPoint( String endPointAddr, String nameSpace, String method, String[] params, Object[] values) {
Map result = null;
Schema schema = null;
try {
//创建一个服务
Service service = new Service();
//建立服务调用实例
Call call = ( Call ) service.createCall();
//设定调用路径
call.setTargetEndpointAddress( new URL( endPointAddr ) );
call.setUseSOAPAction(true);
//设定调用方法
call.setOperationName( new QName( nameSpace, method ) );
call.setSOAPActionURI( nameSpace + method );
call.setReturnType( XMLType.XSD_SCHEMA );
for (String param : params) {
call.addParameter( new QName( nameSpace, param ), XMLType.XSD_STRING, ParameterMode.IN );
}
schema = (Schema) call.invoke(values);
//暂时不考虑返回值
// MessageElement[] msgele = schema.get_any();
// List<MessageElement> msgElmtHead = msgele[0].getChildren();
// // 消息头,DataSet对象
// result = new HashMap<>();
// for (MessageElement element : msgElmtHead) {
// result.put(element.getName(), element.getValue());
// }
} catch ( Exception e ) {
e.printStackTrace();
result = null;
}
return result;
}
/*依赖
<!-- axis 1.4 jar start -->
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.2</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-saaj</artifactId>
<version>1.4</version>
</dependency>
<!-- axis 1.4 jar end -->
*/