net.cloudkit.enterprises.ws.SuperPassParaProxyTest.java Source code

Java tutorial

Introduction

Here is the source code for net.cloudkit.enterprises.ws.SuperPassParaProxyTest.java

Source

/*
 * Copyright (C) 2015. The CloudKit Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.cloudkit.enterprises.ws;

import org.apache.commons.compress.compressors.deflate.DeflateCompressorInputStream;

import javax.xml.namespace.QName;
import javax.xml.ws.Holder;
import javax.xml.ws.Service;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.net.URL;

/**
 * QP ?
 */
public class SuperPassParaProxyTest {

    public static void main(String[] args) throws Exception {

        // CodeLists_Const???XML?
        // MFT2008? RMFT8ChangeReasonCode (AlphaNumber)
        // 001   ?
        // 002   
        // 003   ?
        // 004   ????
        // 005   ????
        // 006   ??????
        // 007   ????
        // 008   ????
        // 009   ??????
        // 010   ????
        // 011   ???
        // 012   ?
        // 013   ?
        // 014   ?
        // 015   ??
        // 999   
        //
        // MFT2008 RMFT8DeclareTypeCode (AlphaNumber)
        // MT1401   ??
        // MT2401   ???
        // MT5401   ??
        // MT5402   ??
        // MT3402   ?
        // MT7402   ??
        // MT8401   ??
        // MT8402   ??
        // MT8403   ???
        // MT8404   ???
        // MT4401   ??
        // MT4402   ??
        // MT4403   ??
        // MT4404   ??
        // MT4405   ??
        // MT4406   ??
        //
        // MFT2008 RMFT8DeclareTypeCodeStat (AlphaNumber)
        // MT1401   ??
        // MT2401   ???
        // MT5401   ??
        // MT5402   ??
        // MT3402   ?
        // MT7402   ??
        // MT8401   ??
        // MT8402   ??
        // MT8403   ???
        // MT8404   ???
        // MT4401   ??
        // MT4402   ??
        // MT4403   ??
        // MT4404   ??
        // MT4405   ??
        // MT4406   ??
        //
        // MFT2008 RMFT8FunctionTypeCode (AlphaNumber)
        // 2   
        // 3   
        // T   
        // 5   ?
        // 9   ???
        // 0   ???
        // 11   
        //
        // MFT2008 (AlphaNumber) RMFT8ReponseTypeCode
        // M1   M1-
        // M2   M2-??
        // M3   QP
        // 01   01-?
        // 02   02-
        // 03   03-?
        // 11   11-
        // 12   12-
        // 13   13-??
        // T   T-
        // D   D-?
        // E1   E1-??
        // E2   E2-?
        // E3   E3-??
        // E4   E4-?
        //
        // ?  (AlphaNumber) MasterAffirmSign
        // 0   
        // 1   ?
        // 2   ?
        //
        // ? ? (AlphaNumber) DeclareType
        // 0   
        // 1   
        //
        // MFT2008?? RMFT8MobileTypeCode (AlphaNumber)
        // MT4403   ??
        // MT4404   ??
        // MT4405   ??
        // MT4406   ??
        //
        // ?  RMFT8MobileFuncCode (AlphaNumber)
        // M1   
        // M2   ??
        // M3   QP
        // 2   
        // 3   
        // T   
        // 5   ?
        // 9   ?
        // 0   (??)
        // 11   

        URL url = new URL("http://ceesb.chinaport.gov.cn/SuperPassParaProxy/Proxy_Services/SuperPass_Proxy?wsdl");
        QName qname = new QName("http://www.cneport.com/webservices/superpass", "SuperPass");
        Service service = Service.create(url, qname);
        SuperPass superPass = service.getPort(SuperPass.class);

        /*
        String serviceName = "eport.superpass.pub.para.CustomsFlagStatus";
        byte[] requestContext = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><RequestContext><Group name=\"SystemInfo\"><Key name=\"ClientId\">5300001128334</Key><Key name=\"CertNo\">c1f4bb</Key><Key name=\"SaicSysNo\">618882068</Key><Key name=\"DEP_IN_CODE\">5300</Key><Key name=\"REG_CO_CGAC\">4403941436</Key><Key name=\"ENT_SEQ_NO\">000000000000063462</Key><Key name=\"IcCode\">8800000246746</Key><Key name=\"OperatorName\"></Key><Key name=\"DEP_CODE_CHG\">5300</Key><Key name=\"NAME_FULL\">???</Key></Group><Group name=\"DataPresentation\"><Key name=\"SignatureAlgorithm\" /><Key name=\"EncryptAlgorithm\" /><Key name=\"CompressAlgorithm\" /></Group></RequestContext>".getBytes();
        byte[] requestData = "<?xml version=\"1.0\"?>\n<CustomsFlagStatusRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n<CustomsCode>5300</CustomsCode>\n</CustomsFlagStatusRequest>".getBytes();
        */

        // ??
        String serviceName = "eport.superpass.pub.para.LoadIntoMemory";
        byte[] requestContext = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><RequestContext><Group name=\"SystemInfo\"><Key name=\"ClientId\">5300001128334</Key><Key name=\"CertNo\">b6c29b</Key><Key name=\"SaicSysNo\">618882068</Key><Key name=\"DEP_IN_CODE\">5300</Key><Key name=\"REG_CO_CGAC\">4403941436</Key><Key name=\"ENT_SEQ_NO\">000000000000063462</Key><Key name=\"SessionId\">2015-7-14</Key><Key name=\"IcCode\">8910000270086</Key><Key name=\"OperatorName\">??</Key><Key name=\"DEP_CODE_CHG\">5300</Key><Key name=\"NAME_FULL\">???</Key></Group><Group name=\"DataPresentation\"><Key name=\"SignatureAlgorithm\" /><Key name=\"EncryptAlgorithm\" /><Key name=\"CompressAlgorithm\" /></Group></RequestContext>"
                .getBytes();
        // ? MFT8TrayType
        // SELECT TRAY_CODE,TRAY_NAME FROM MFT8_TRAY_TYPE ORDER BY TRAY_CODE
        // ??? RMFT8TransportType
        // SELECT CODE, NAME FROM mft8_transport_type ORDER BY CODE
        // ? RMFT8CustomsCode
        // SELECT customs_CODE, customs_NAME FROM customs ORDER BY customs_CODE
        // ??(CN003) RMFT8PortCode
        // SELECT CODE, CHNAME FROM mft8_location_name ORDER BY CODE
        // ? RMFT8Curr
        // SELECT CODE, NAME FROM MFT8_ROAD_CURR ORDER BY CODE
        // ? RMFT8ReceiptPlace
        // SELECT CODE, NAME FROM mft8_entity ORDER BY CODE
        // ? RMFT8CountryCode
        // SELECT CODE, NAME FROM mft8_country_code ORDER BY CODE
        // ?? RMFT8CustomStatus
        // SELECT CODE, NAME FROM MFT8_ROAD_CUSTOMS_STATUS ORDER BY CODE
        // ?? RMFT8TransPayCode
        // SELECT CODE, NAME FROM MFT8_ROAD_PAYMENT_METHOD ORDER BY CODE
        // ??(CN005) RMFT8WrapTypeCode
        // SELECT CODE, NAME FROM mft8_packaging ORDER BY CODE
        // ??? RMFT8TransLicCode
        // SELECT CODE, NAME FROM MFT8_CONTR_CAR_COND ORDER BY CODE
        // ?? RMFT8PortWorkCode
        // SELECT CODE, NAME FROM MFT8_HAND_INSTR ORDER BY CODE
        // ?? RMFT8CommunicationCode
        // SELECT CODE, NAME FROM mft8_communi_type ORDER BY CODE
        // ? RMFT8PostCode
        // SELECT CODE, NAME FROM mft8_post_code ORDER BY CODE
        //  RMFT8EquipSizeCode
        // SELECT CODE, SHAPE,LENGTH,HEIGHT,WIDTH FROM mft8_equip_size_type ORDER BY CODE
        // ??? RMFT8EquipSupCode
        // SELECT CODE, NAME FROM MFT8_EQUIP_SUP ORDER BY CODE
        // ?? RMFT8EquipFullCode
        // SELECT CODE, NAME FROM mft8_equip_full ORDER BY CODE
        // ?? RMFT8EquipSealCode
        // SELECT CODE, NAME FROM mft8_seal_agency ORDER BY CODE
        // ??? RMFT8DanGoodsCode
        // SELECT CODE, CHNAME FROM mft8_dan_goods ORDER BY CODE
        // ? RMFT8CusProCode
        // SELECT CODE, NAME FROM mft8_cus_procedure ORDER BY CODE
        // ?/? RMFT8TransportSplitCode
        // SELECT CODE, NAME FROM mft8_indication ORDER BY CODE
        // ?? RMFT8DamageAreaCode
        // SELECT CODE, NAME FROM MFT8_DAMAGE_AREA ORDER BY CODE
        // ?? RMFT8DamageTypeCode
        // SELECT CODE, NAME FROM MFT8_DAMAGE_TYPE_DES ORDER BY CODE
        // IATA?(UN005) RMFT8IATACode
        // SELECT CODE, NAME FROM mft8_iata_code ORDER BY CODE
        // ????(UN009) RMFT8LocodePort
        // SELECT CODE, NAME FROM mft8_un_locode_port ORDER BY CODE
        // RMFT8ComplexCode
        // SELECT CODE_TS, G_NAME FROM complex ORDER BY CODE_TS
        byte[] requestData = "<?xml version=\"1.0\"?>\n<LoadIntoMemoryRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n<QuerySql>SELECT CODE, NAME FROM mft8_un_locode_port ORDER BY CODE</QuerySql>\n</LoadIntoMemoryRequest>"
                .getBytes();

        Holder<byte[]> responseData = new Holder<byte[]>();
        System.out.println(new String(superPass.service(serviceName, requestContext, requestData, responseData)));

        // deflate 
        DeflateCompressorInputStream gis = new DeflateCompressorInputStream(
                new ByteArrayInputStream(responseData.value));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int count;
        byte data[] = new byte[1024];
        while ((count = gis.read(data, 0, 1024)) != -1) {
            baos.write(data, 0, count);
        }
        gis.close();

        data = baos.toByteArray();
        baos.flush();
        baos.close();

        System.out.println(new String(data));
        // System.out.println(new String(responseData.value, "UTF-8"));
    }
}