java调用CCB的XAI的入站服务

package test;


import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.apache.axis2.transport.http.HttpTransportProperties.ProxyProperties;


public class CCBWebServiceClient {
//静态变量
private static EndpointReference EPR = new EndpointReference("http://WSDL的URL");
private static OMFactory fac = OMAbstractFactory.getOMFactory();
private static OMNamespace omNs = fac.createOMNamespace("http://oracle.com/CM_TEST_XAI.xsd", "xsd");//wsdl中的namespace
  
  public static void main(String args[]) throws AxisFault{   
        ServiceClient sender = new ServiceClient();
        /****************************CM_TEST_XAI方法,如果有其他方法,以此类推**************************************/
        sender.setOptions(buildOptions("http://ouaf.oracle.com/spl/XAIXapp/xaiserver/CM_TEST_XAI"));//注意“CM_TEST_XAI”是方法名
        OMElement result = sender.sendReceive(buildParam("CM_TEST_XAI",new String[]{"参"},new String[]{"值"}));
        //传递多个参数:OMElement result = sender.sendReceive(buildParam("方法名",new String[]{"参数名1","参数名2"},new String[]{"值1","值2"}));
        //空参:OMElement result = sender.sendReceive(null);
        /************************************************************************************************/
        System.out.println(result);
  }
 /**
  * 传参函数
  */
 public static  OMElement buildParam(String method,String[] arg,String[] val) {
        OMElement data = fac.createOMElement(method,omNs);
        for(int i=0;i<arg.length;i++){
        OMElement inner = fac.createOMElement(arg[i], omNs);
        inner.setText(val[i]);
        data.addChild(inner);
        }
        return data;
 }
 
 /**
  * @see 设置连接属性
  * @return
 * @throws AxisFault 
  */
 public static Options  buildOptions(String action) throws AxisFault{
Options options = new Options();
        options.setTo(EPR);
        options.setProperty(HTTPConstants.CHUNKED, "false");//设置长度不受限制.
       // options.setProperty(HTTPConstants.PROXY, buildProxy());//打开即用代理
        /****************************添加账号密码*******************************************************/
        HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
        auth.setUsername("账号");
        auth.setPassword("密码");
        options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,auth);  
        /*******************************************************************************************/
        options.setAction(action);//此处根据报错情况决定是否注释
        return options;
 }
 /**
  * 设置代理
  */
 public static ProxyProperties buildProxy(){
     ProxyProperties proxyProperties=new ProxyProperties();
        proxyProperties.setProxyName("代理地址");
        proxyProperties.setProxyPort(8080);
        return proxyProperties;
 }
 
 
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值