Search in sources :

Example 6 with Service

use of org.apache.axis.client.Service in project portal by ixinportal.

the class ReceiptConfigService method receiptTest.

// 电票查询票数测试
public Map<String, Object> receiptTest(String idCode) {
    Map<String, Object> re = new HashMap<String, Object>();
    re.put("retCode", false);
    re.put("retMsg", "测试失败");
    Call call;
    String val = "";
    String content = "<REQUEST_COMMON_FPKCCX class='REQUEST_COMMON_FPKCCX'>  <NSRSBH>" + idCode + "</NSRSBH> </REQUEST_COMMON_FPKCCX> ";
    try {
        String xml = getCommonXml("DFXJ1001", new BASE64Encoder().encodeBuffer(content.getBytes("UTF-8")));
        String ssl_store = "D:/cer/fapiao_ceshi.truststore";
        String ssl_pwd = "654321";
        System.setProperty("javax.net.ssl.trustStore", ssl_store);
        System.setProperty("javax.net.ssl.keyStorePassword", ssl_pwd);
        HostnameVerifier hv = new HostnameVerifier() {

            public boolean verify(String urlHostName, SSLSession session) {
                System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
                return true;
            }
        };
        HttpsURLConnection.setDefaultHostnameVerifier(hv);
        Service s = new Service();
        call = (Call) s.createCall();
        call.setTargetEndpointAddress(new java.net.URL("https://202.104.113.26:8999/fpt_dsqz/services/DZFPService"));
        call.setOperation("doService");
        Object[] fn01 = { xml };
        System.out.println(xml);
        val = (String) call.invoke(fn01);
        if (StringUtils.isNotEmpty(val)) {
            re.put("retCode", true);
            re.put("retMsg", "测试成功");
        }
        System.out.println(val);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return re;
}
Also used : Call(org.apache.axis.client.Call) HashMap(java.util.HashMap) BASE64Encoder(sun.misc.BASE64Encoder) SSLSession(javax.net.ssl.SSLSession) Service(org.apache.axis.client.Service) HostnameVerifier(javax.net.ssl.HostnameVerifier)

Example 7 with Service

use of org.apache.axis.client.Service in project OpenTripPlanner by opentripplanner.

the class NoDownloadIDException method getDownloadURLs.

private List<URL> getDownloadURLs() {
    List<URL> urls = new ArrayList<URL>();
    List<String> payloads = getValidateElements();
    log.info("Getting urls from request validation service");
    String RTendpointURL = "http://extract.cr.usgs.gov/requestValidationService/services/RequestValidationService";
    try {
        int nd = 0;
        for (String payload : payloads) {
            // FIXME document why this sleep call exists. Rate limiting?
            sleep(2000);
            Service RTservice = new Service();
            Call RTcall = (Call) RTservice.createCall();
            RTcall.setTargetEndpointAddress(new java.net.URL(RTendpointURL));
            // Service method
            RTcall.setOperationName(new QName("edc.usgs.gov", "processAOI"));
            String response = (String) RTcall.invoke(new Object[] { payload });
            Document doc = stringToDoc(response);
            XPathExpression expr = makeXPathExpression("//ns1:processAOIReturn/text()");
            String xml = expr.evaluate(doc);
            if (!xml.equals("")) {
                // case where response is wrapped
                doc = stringToDoc(xml);
            }
            // ... which seems to get prematurely decoded
            // xml = xml.replace("&", "&amp;");
            expr = makeXPathExpression("//PIECE/DOWNLOAD_URL");
            NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
            // hopefully, this will be a list of one.
            if (nodes.getLength() > 1) {
                log.debug("One of our NED tiles requires more than one tile from the server.  This is slightly inefficient, and sort of yucky.");
            }
            for (int i = 0; i < nodes.getLength(); ++i) {
                Node node = nodes.item(i);
                String urlString = node.getTextContent().trim();
                log.info("Getting URL {}/{}", ++nd, payloads.size());
                log.debug("Adding NED URL: " + urlString);
                // use one specific, less-broken server at usgs
                // urls returned are broken
                urlString = urlString.replaceAll(" ", "+");
                // sometimes.
                URL url = new URL(urlString);
                urls.add(url);
            }
        }
        return urls;
    } catch (Exception e) {
        throw new RuntimeException("Error getting data from USGS Request Validation Server", e);
    }
}
Also used : Call(org.apache.axis.client.Call) URL(java.net.URL) QName(javax.xml.namespace.QName) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Service(org.apache.axis.client.Service) Document(org.w3c.dom.Document) URL(java.net.URL) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 8 with Service

use of org.apache.axis.client.Service in project csb-sdk by aliyun.

the class AxisTest method testCmdWsCaller.

@Test
public void testCmdWsCaller() throws Exception {
    String ak = "ak";
    String sk = "sk";
    String apiName = "PING";
    String apiVersion = "vcsb.ws";
    Service service = new Service();
    Call call = AxisCallWrapper.createCallWrapper(service, ak, sk, apiName, apiVersion);
    call.setTargetEndpointAddress("http://localhost:9081/PING/vcsb.ws/ws2ws");
    call.setOperationName(new QName("http://hc.wsprocess.csb.alibaba.com/", "ping"));
    // call.setEncodingStyle(null);
    // 设置要传递的参数
    call.addParameter(// 设置要传递的参数
    "arg0", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
    Object[] args = { "wiseking" };
    Object ret = call.invoke(args);
    System.out.println("ret=" + ret);
}
Also used : Call(org.apache.axis.client.Call) QName(javax.xml.namespace.QName) Service(org.apache.axis.client.Service) Test(org.junit.Test)

Aggregations

Service (org.apache.axis.client.Service)8 Call (org.apache.axis.client.Call)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 QName (javax.xml.namespace.QName)3 Iterator (java.util.Iterator)2 Callback (net.sf.cglib.proxy.Callback)2 FastClass (net.sf.cglib.reflect.FastClass)2 ServiceException (com.google.api.ads.common.lib.exception.ServiceException)1 AxisCompatible (com.google.api.ads.common.lib.soap.compatability.AxisCompatible)1 StringReader (java.io.StringReader)1 BigInteger (java.math.BigInteger)1 URI (java.net.URI)1 URL (java.net.URL)1 Remote (java.rmi.Remote)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 TimeZone (java.util.TimeZone)1 Vector (java.util.Vector)1 NamingException (javax.naming.NamingException)1