https

http://hc.apache.org/httpclient-3.x/sslguide.html

System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

http://ws.apache.org/axis2/1_3/http-transport.html

package briup;

import javax.xml.namespace.QName;

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;

public class WsClient {

  private RPCServiceClient serviceClient;
  private Options options;
  private EndpointReference targetEPR;
  
  public WsClient(String endpoint) throws AxisFault {
    serviceClient = new RPCServiceClient();
    options = serviceClient.getOptions();
    targetEPR = new EndpointReference(endpoint);
    options.setTo(targetEPR);
  }
  public Object[] invokeOp(String targetNamespace, String opName,
      Object[] opArgs, Class<?>[] opReturnType) throws AxisFault,
      ClassNotFoundException {
    // 设定操作的名称
    QName opQName = new QName(targetNamespace, opName);
    // 设定返回值
    
    //Class<?>[] opReturn = new Class[] { opReturnType };

    // 操作需要传入的参数已经在参数中给定,这里直接传入方法中调用
    return serviceClient.invokeBlocking(opQName, opArgs, opReturnType);
  }
  /**
    * @param args
    * @throws AxisFault 
    * @throws ClassNotFoundException 
    */
  public static void main(String[] args) throws AxisFault, ClassNotFoundException {
    // TODO Auto-generated method stub
    final String endPointReference = "http://localhost:8080/axis2/services/ws";
    final String targetNamespace = "http://briup";
    WsClient client = new WsClient(endPointReference);
    
    String opName = "sayHello";
    Object[] opArgs = new Object[]{"Repace中心"};
    Class<?>[] opReturnType = new Class[]{String[].class};
    
    Object[] response = client.invokeOp(targetNamespace, opName, opArgs, opReturnType);
    System.out.println(((String[])response[0])[0]);
  }

}



http://hideto.iteye.com/blog/56835
http://worldllg.iteye.com/blog/455271

你可能感兴趣的:(apache,.net,Security,Blog,sun)