Java施用Axis调用.NET语言开发的WebService

Java使用Axis调用.NET语言开发的WebService

Java结合Axis调用.net语言开发的WebService

=====================具体参见代码=================================

package com;

import java.net.URL;

import javax.xml.namespace.QName;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;

/**
 * 平台请求客户端(Axis+WebService)
 * 所需jar包
 * jaxrpc.jar
 * axis.jar
 * wsdl4j-1.5.1.jar
 * commons-discovery-0.2.jar
 * commons-logging-1.0.4.jar
 *
 */
public class Client {

 /**
  * WebService请求(因只有一个参数@_@)
  * @param url   服务器请求URL
  * @param namespace  WebService命名空间(targetNamespace="http://tempuri.org/")
  * @param methodName 方法名称(<xs:element name="SubmitOrder" />)
  * @param parameterName 参数名称(参数名称必须和WebService方法的参数的名称一样
  *       {<xs:element minOccurs="0" name="args" nillable="true" type="xs:string" />})
  * @param actionUrl  方法对应的ActionURI(<wsdl:input wsaw:Action="actionUrl" message="tns:xxx" />)
  * @param request   请求报文
  */
 public static String send(String url, String namespace, String methodName, String parameterName, 
   String actionUrl, String request) throws Exception {
  Service service = new Service();
  Call call = (Call)service.createCall();
  call.setOperationName(new QName(namespace, methodName));
  call.addParameter(new QName(namespace, parameterName), XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
  call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING); 
  call.setTargetEndpointAddress(new URL(url));
  call.setUseSOAPAction(true);
  call.setSOAPActionURI(actionUrl);
  String response = (String)call.invoke(new String[]{request});
  
  return response;
 }
 }