package com.adsionline.ADSIShippingWS;
//package ibase.webitm.adsi;

import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.jar.Attributes.Name;

import javax.imageio.ImageIO;
import javax.xml.parsers.SAXParser;
import javax.xml.soap.Node;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.axis.client.Call;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.message.MessageElement;
import org.apache.axis.utils.Mapping;
import org.apache.axis.wsdl.fromJava.Types;
import org.apache.axis.wsdl.gen.Parser;
import org.apache.axis.wsdl.symbolTable.MessageEntry;
import org.w3c.dom.Element;
import org.xml.sax.helpers.DefaultHandler;

import sun.misc.BASE64Decoder;

import com.adsionline.ADSIShippingWS.*;
//import sun.misc.BASE64Decoder;
public class ADSIServerCalling {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		try {
    		
			
			ADSIShippingLocator locator = new ADSIShippingLocator();
    		ADSIShippingSoap  soap = locator.getADSIShippingSoap(new URL("http://172.20.0.137/ADSIShippingWS/ADSIShipping.asmx"));
    		//System.out.println("ADSIServerCalling.main() ["+soap.getServicesListForShipper("Taro Fulfillment").isSuccess());
    		StringListReturn std =  soap.getCarrierSymbolsList();
    		//Shipment shipment = new Shipment();
    		Shipment2 shipment2 = new Shipment2();
    		
    		///////////////////////////////////////////////
   /* 		org.apache.axis.client.Service service1 = new org.apache.axis.client.Service();
			Call call = (Call)service1.createCall();
			//Call call = locator.getCall();
			System.out.println("Running again the thread1...");
			call.setTargetEndpointAddress(new java.net.URL("http://172.20.0.137/ADSIShippingWS/ADSIShipping.asmx"));
			System.out.println("Running again the thread2...");
			//System.out.println("methodName :["+methodName+"]");
			
			//Changed by Dhruv on 05/12/2006 for testing .net webservice.Start
			//call.setOperationName(methodName);
			call.setOperationName( new javax.xml.namespace.QName("http://adsionline.com/ADSIShippingWS/", "ShipWithLabel") );
			System.out.println("Running again the thread3...");
			call.setUseSOAPAction(true);
			System.out.println("Running again the thread4...");
			call.setSOAPActionURI( "http://adsionline.com/ADSIShippingWS/" + "ShipWithLabel" );
			System.out.println("Running again the thread5...");
			//call.setReturnType(XMLType.XSD_STRING);
			System.out.println("Running again the thread6...");
			//String returnValue = (String)call.invoke(new Object[] {});
			call.invoke();*/
			//System.out.println("Running again the thread7...["+call.+"]");
			//////////////////////////////////////////////////////
    		
    		
    		
    		
    		///
    		/*org.apache.axis.description.TypeDesc typeDesc = shipment2.getTypeDesc();
			typeDesc.setXmlType(new javax.xml.namespace.QName("http://adsionline.com/ADSIShippingWS/", "item"));
			
			org.apache.axis.description.ElementDesc  elemField = new org.apache.axis.description.ElementDesc();
			elemField.setFieldName("key");
			elemField.setXmlName(new javax.xml.namespace.QName("http://adsionline.com/ADSIShippingWS/", "Key"));
			elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
			elemField.setMinOccurs(0);
			elemField.setNillable(true);
			typeDesc.addFieldDesc(elemField);
			elemField.setFieldName("value");
			elemField.setXmlName(new javax.xml.namespace.QName("http://adsionline.com/ADSIShippingWS/", "value"));
			elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
			elemField.setMinOccurs(0);
			elemField.setNillable(true);
			typeDesc.addFieldDesc(elemField);*/
    		///
    		
    		//shipment2.setID("ABC");
    		
    		Address recipient = new Address();
    		//recipient.setID("ABC");
    		recipient.setContact("Julius Peppers");
    		recipient.setCompany("Chicago Bears");
    		recipient.setAddress1("1410 Museum Capmpus Dr");
    		recipient.setAddress2("Locker #90");
    		recipient.setCity("Chicago");
    		recipient.setState("IL");    		
    		recipient.setPostalCode("60607");
    		
    		
    		System.out.println("Ist country.getISO3()["+soap.getCountry("ISO2", "IN").getResponseCountry().getFriendlyName());
    		
    		Country country = soap.getCountry("ISO2", "US").getResponseCountry();
    		//country.setFriendlyName("United States");
    		//System.out.println("Ist country.getISO3()["+country.getFriendlyName()+"]");
    		//System.out.println("Ist country.getISO3()["+country.getISO3()+"]");
    	
    		recipient.setCountry(country);
    		recipient.setPhone("8478841940");
    		shipment2.setRecipient(recipient );
			
			Service service = new Service();
			
			//service.setFriendlyName("FEDGND");
			service.setFriendlyName("UPSGND");
			//service.setSymbol("ADSI.FEDEXGND.GND");
			System.out.println("get service symbol ["+service.getSymbol()+"]");
			System.out.println("get getFriendlyName ["+service.getFriendlyName()+"]");
			System.out.println("Like this getFriendlyName ["+soap.getServices().getServiceList()[0].getFriendlyName());
			//soap.getCarriers().getCarrierList()[0]
			//service.setSymbol("ADSI.FEDEXGND.GND");
			//service.setSymbol("UPS WORLDW");		//
			//service.setSymbol("TANDATA_UPS.UPS");			
			shipment2.setService(service);
			
    		shipment2.setTerms(EnumTerms.trmSHIPPER);    		
    		
    		java.util.Date date = new Date();
    		Calendar calendar = Calendar.getInstance();
    		calendar.setTime(date);
    		shipment2.setShipDate(calendar);  		
			
			shipment2.setResidentialFlag(false);
			shipment2.setProofOfDeliveryFlag(false);
			shipment2.setSignatureReleaseFlag(false);
			shipment2.setSignatureRequiredFlag(true);
			shipment2.setSaturdayDeliveryFlag(false);
			shipment2.setShipDate(calendar);
			shipment2.setThirdPartyBillingFlag(false);
			shipment2.setHALFlag(false);
			shipment2.setShipperName("Taro Commercial");
			shipment2.setManifestAction(EnumManifestAction.maHOLD);// maHOLD Do not commit to manifest immediately
			//shipment2.setConsigneeBillingFlag(false);
			//shipment2.setConsigneeAccount("");
		
			shipment2.setConsigneeBillingFlag(false);
			
			shipment2.setShipperReference("xyz123");//As per Taro use PTCN(Pick Ticket Control No)
    		shipment2.setConsigneeReference("abcdfg");//As per Taro it is sorder.cust_pord
			
			//EnumTimeInTransit timeInTransit = new EnumTimeInTransit("tntFOREVER");
			//shipment2.getTimeInTransit().
			shipment2.setTimeInTransit(EnumTimeInTransit.tntFOREVER);
			//MessageElement me = new MessageElement(new javax.xml.namespace.QName("http://adsionline.com/ADSIShippingWS/"), "item");	
			//MessageElement me = new MessageElement("item", "");
		/*	MessageElement me = new MessageElement("","item");
			me.setObjectValue("");
			Element e = me.getAsDOM();
			
			e.removeAttribute("xsi:type");
			e.removeAttribute("xmlns:ns1");
			e.removeAttribute("xmlns:xsd");
			e.removeAttribute("xmlns:xsi");
			me = new MessageElement(e);
			
			
			///
			MessageElement me1 = new MessageElement("","Key");
			//me1.setObjectValue("FUEL_SURCHARGE");
			//me1.setNodeValue("FUEL_SURCHARGE");
			//me1.setValue("FUEL_SURCHARGE");
			Element e1 = me1.getAsDOM();
			
			e1.removeAttribute("xsi:type");
			e1.removeAttribute("xmlns:ns1");
			e1.removeAttribute("xmlns:xsd");
			e1.removeAttribute("xmlns:xsi");
			//e1.setTextContent("FUEL_SURCHARGE");
			//e1.setNodeValue("FUEL_SURCHARGE");
			me1 = new MessageElement(e1);
			//me1.setNodeValue("test");
			
			//me1.setValue("FUEL_SURCHARGE");
			//me1.setNodeValue("FUEL_SURCHARGE");
			
			me1.addTextNode("FUEL_SURCHARGE");
			//me1.setNodeValue("FUEL_SURCHARGE");
			
			MessageElement me2 = new MessageElement("","value");
			Element e2 = me2.getAsDOM();
			
			e2.removeAttribute("xsi:type");
			e2.removeAttribute("xmlns:ns1");
			e2.removeAttribute("xmlns:xsd");
			e2.removeAttribute("xmlns:xsi");
			//e2.setTextContent("4.42");
			//e2.setNodeValue("4.42");
			me2 = new MessageElement(e2);
			me2.addTextNode("4.42");
			System.out.println(" Name1vvvvvvvvvvvv["+me1.getName()+"]");
			System.out.println(" Node Name1["+me1.getNodeName()+"]");
			System.out.println(" Node Value1["+me1.getNodeValue()+"]");
			System.out.println(" Node Value2["+me1.getValue()+"]");
			me.addChild(me1);
			me.addChild(me2);
			//
			
			System.out.println(" Namecccccccccc["+me.getName()+"]");
			System.out.println(" Node Name["+me.getNodeName()+"]");
			System.out.println(" Node Value["+me.getNodeValue()+"]");
			
			System.out.println(" Name1vvvvvvvvvvvv["+me1.getName()+"]");
			System.out.println(" Node Name1["+me1.getNodeName()+"]");
			System.out.println(" Node Value1["+me1.getNodeValue()+"]");
			
			System.out.println(" Name2bbbbbbbbbbbbb["+me2.getName()+"]");
			System.out.println(" Node Name2["+me2.getNodeName()+"]");
			System.out.println(" Node Value2["+me2.getNodeValue()+"]");
			me.addChildElement("key");
			me.addChildElement("value");
			MessageElement[] _any ={me};
			//_any[0].addTextNode("test");
			customFieldShip.set_any(_any);*/
			//shipment2.setCustomFields(customFieldShip);
			
		//	System.out.println(" Custom Fields["+shipment2.getCustomFields().get_any()[0].getName()+"]");
			
			/*com.adsionline.ADSIShippingWS.Address CODReturnAddress,
	           com.adsionline.ADSIShippingWS.PackageCustomFields customFields,
	           com.adsionline.ADSIShippingWS.IDangerousGoods[] dangerousGoods,
	           com.adsionline.ADSIShippingWS.CommodityInfo[] commodityInfos));*/
			Address cODReturnAddress = new Address();
			cODReturnAddress.setCity("");
			
			PackageCustomFields customFields  = new PackageCustomFields();
			
			/*boolean accessibleFlag,
	           boolean cargoOnlyFlag,
	           boolean limitedQtyFlag,
	           java.lang.String ID,
	           java.lang.String _class,
	           java.lang.String description,
	           java.lang.String quantity,
	           java.lang.String packaging,
	           com.adsionline.ADSIShippingWS.EnumDGPackingGroup packingGroup,
	           long labels,
	           java.lang.String unitOfMeasure*/
			
			IATADangerousGoods iataDangerousGoods = new IATADangerousGoods();
			
			IDangerousGoods[] dangerousGoods = new IDangerousGoods[1];
			//dangerousGoods[0] = new IDangerousGoods(true,false,false,"ID1","En","","","",EnumDGPackingGroup.dgpgClassI,1,"kg");
			
			/*IATADangerousGoods iataDangerousGoods = new IATADangerousGoods();
			iataDangerousGoods.set*/
			
			/*java.lang.String description,
           double quantity,
           double unitValue,
           double unitWeight,
           java.lang.String productCode,
           java.lang.String harmonizedCode,
           java.lang.String ECCN,
           java.lang.String licenseExportNumber,
           java.util.Calendar exportNumberExpireDate,
           com.adsionline.ADSIShippingWS.EnumUnitOfMeasure unitOfMeasure,
           com.adsionline.ADSIShippingWS.Country originCountry,
           com.adsionline.ADSIShippingWS.Country ultimateDestinationCountry,
           boolean naftaFlag,
           java.lang.String ITARExemptionNumber,
           com.adsionline.ADSIShippingWS.EnumLicenseException licenseExemptionSymbol,
           java.lang.Integer grossWeightInWholeKG,
           com.adsionline.ADSIShippingWS.EnumUnitOfMeasure secondUnitOfMeaseure,
           java.lang.Double secondQuantity,
           java.lang.String marksAndNumbers,
           java.lang.String exportCode,
           java.lang.Boolean vehicleFlag,
           java.lang.String vehicleID,
           java.lang.String vehicleIDType,
           java.lang.String vehicleTitle,
           java.lang.String vehicleTitleState,
           java.lang.String ODTCITARExemptionNumber,
           java.lang.String ODTCRegistrationNumber,
           java.lang.Boolean ODTCSignifactMilitaryEquiptment,
           java.lang.Boolean ODTCEligiblePartyCertification,
           java.lang.String ODTCUSMLCategoryCode,
           com.adsionline.ADSIShippingWS.EnumUnitOfMeasure ODTCUnitOfMeasure,
           java.lang.Double ODTCQuantity,
           java.lang.Double AESUnitQuantity,
           java.lang.Double AESUnitValue,
           com.adsionline.ADSIShippingWS.EnumUnitOfMeasure AESUnitOfMeasure*/
			
			
			
			
			CommodityInfo[] commodityInfos = new CommodityInfo[1];
			String harmonizedCode = "3004909180";
			String vehicleIDType = "";
			boolean naftaFlag = false;
			Country originCountry = new Country();
			originCountry.setFriendlyName("United States");			
			String exportCode = "";
			double secondQuantity = 120;
			Integer grossWeightInWholeKG = 100;			
			String vehicleTitleState = "";
			Country ultimateDestinationCountry = new Country();			
			String marksAndNumbers = "";			
			//Calendar exportNumberExpireDate;
			String vehicleTitle = "";
			String vehicleID = "";
			boolean vehicleFlag = false;
			String ITARExemptionNumber = null;
			double AESUnitQuantity = 23;
			String ODTCRegistrationNumber = "";
			boolean ODTCSignifactMilitaryEquiptment = false;			
			String ODTCUSMLCategoryCode = null;
			boolean ODTCEligiblePartyCertification = false;			
			String ODTCITARExemptionNumber = null;
			double AESUnitValue = 23;
			double ODTCQuantity = 23;
			commodityInfos[0] = new CommodityInfo("", 0, 0, 0, "", harmonizedCode, "", "", calendar, EnumUnitOfMeasure.uomC, originCountry, ultimateDestinationCountry, naftaFlag, ITARExemptionNumber, EnumLicenseException.leBaggage, grossWeightInWholeKG, EnumUnitOfMeasure.uomC, secondQuantity, marksAndNumbers, exportCode, vehicleFlag , vehicleID, vehicleIDType, vehicleTitle, vehicleTitleState, ODTCITARExemptionNumber, ODTCRegistrationNumber, ODTCSignifactMilitaryEquiptment, ODTCEligiblePartyCertification, ODTCUSMLCategoryCode, EnumUnitOfMeasure.uomCKG, ODTCQuantity, AESUnitQuantity, AESUnitValue, EnumUnitOfMeasure.uomCG);
			
			
			//MessageElement[] _any =  new MessageElement[10];
			//Mapping map = new Mapping("http://adsionline.com/ADSIShippingWS/", "item");
			//map.
			//_any[0].addMapping(map);
			/*MessageEntry[] _any =  new MessageEntry[10];
			_any[0].setDynamicVar(key, value);*/
			//_any[0].addChildElement("FSMS_PRINT_LABELTYPE", "ADSI_FEDEX_EXPDOM_THERMAL_LABEL");
			//customFields.set_any(_any);
			//customFields.set_any(_any);
			/*_package[] packages = new _package[1];			
			packages[0] = new _package("",2.1,"10x10x10","","","",false,2,false,2,2,"",false,false,2,EnumPackageType.pkgCUSTOM,false,2,2,cODReturnAddress,customFields,dangerousGoods,commodityInfos);
			//shipment2.setConsigneeAccount("");
			shipment2.setPackages(packages);*/
			//System.out.println("Test="+shipment2.getPackages());
			
			/* ID, weight, dimension,String trackingNumber,String description,String commodityClass, boolean oversizeFlag,
	           double oversizeFee, boolean declaredValueFlag,double declaredValueAmount,double declaredValueCustoms,String billOfLadingComment,
	           boolean hazmatFlag,boolean additionalHandlingFlag,double additionalHandlingFee,EnumPackageType packaging,
	           boolean CODFlag,double CODAmount,int CODPaymentType,Address CODReturnAddress,PackageCustomFields customFields,
	           IDangerousGoods[] dangerousGoods,CommodityInfo[] commodityInfos,NameValuePair[] additionalFields)*/
			
					
			NameValuePair[] NameValuePair = new NameValuePair[1];
			NameValuePair[0] = new NameValuePair();
			
			Package2[] packages2 = new Package2[1];
			packages2[0] = new Package2("123456777777",2.1,"10x10x10",null,null,null,false,2,false,2,2,null,false,false,2,EnumPackageType.pkgCUSTOM,false,2,2,cODReturnAddress,customFields,dangerousGoods,commodityInfos,NameValuePair);
			
					
			packages2[0].setCustomFields(customFields);

			
			shipment2.setPackages2(packages2);
			//shipment2.set
    		ShipWithLabelType labelType = new ShipWithLabelType("PNG");
    		ImageRotation imageRotation = new ImageRotation("Rotation_Default");	
    		
    		
    		System.out.println(" daskjd sdsd  ["+soap.testADSIServer()+"]");    
    		
    		//System.out.println("ADSIServerCalling.main() "+soap.shipWithLabel(shipment2, labelType, imageRotation));
    		ShipmentResultReturn2 objReturn2=soap.shipWithLabel(shipment2, labelType, imageRotation);
    		System.out.println("Test1="+objReturn2.getShipmentResultResponse2());
    		System.out.println("Is successfully Exicuted ["+objReturn2.isSuccess()+"]");
    		System.out.println("Message["+objReturn2.getMessage()+"]");
    		String s="";

    		ShipmentResult2 objShipResult = objReturn2.getShipmentResultResponse2();
    		
    		System.out.println("Ist AMSN Printed For Base["+objShipResult.getAMSN()+"]");
    		System.out.println("Ist Bundel Id Printed For Base["+objShipResult.getBundleID()+"]");
    		System.out.println("Ist Base Id Printed For Base["+objShipResult.getBase()+"]");
    		System.out.println("Ist Discount Id Printed For Base["+objShipResult.getDiscount()+"]");
    		System.out.println("Ist Service Plain text Id Printed For Base["+objShipResult.getServicePlaintext()+"]");
    		System.out.println("Get Total Name["+objShipResult.getTotal()+"]");
    		System.out.println("Get Special Name["+objShipResult.getSpecial()+"]");
    		System.out.println("Get Time in Transit Name["+objShipResult.getTimeInTransit()+"]");
    		System.out.println("Ist Shipment Id Printed For Base["+objShipResult.getShipmentID()+"]");
    		System.out.println("Tracking No["+objShipResult.getPackageResults2()[0].getTrackingNumber()+"]");
    		System.out.println("Image Stream["+objShipResult.getPackageResults2()[0].getBase64Label()+"]");
    		System.out.println("Ist Message Id Printed For Base["+objShipResult.getMessage()+"]");
    		//objShipResult.getPackageResults2()[0]
        	
    		//objShipResult.getPackageResults2()[0].getD
    		//String test1=objReturn2.getMessage();
    		
    		//System.out.println("Test1="+test1);
    		
    		//System.out.println(" sarkar  ["+soap.getNextAMSN().getResponse()+"]"); 
    		
    		//System.out.println(" sarkar  ["+soap.rate(shipment2).getTypeDesc().getElementNameForField("")+"]"); 
    		
    		
    		//Shipment shipment = new Shipment();
    		/*System.out.println(" carriar ["+soap.getCarriers().getCarrierList()+"]");
    		System.out.println(" Shipment Strin ["+shipment2.getTypeDesc().getFields()[0].getFieldName()+"]");
    		FieldDesc[] test =shipment2.getTypeDesc().getFields();
    	
    		System.out.println("windows Printer List["+soap.getWindowsPrintersList().getResponseList()[0]);
    		//test[0].getFieldName();
    		Shipment shipment = new Shipment();
    		shipment.setID("");
    		shipment.setRecipient(recipient );
    		
			soap.rate(shipment );
    		System.out.println("Deserializer"+objReturn2.getDeserializer("",ShipmentResultReturn2.class, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")).getMechanismType());
    		//System.out.println("Serailizer"+shipment2.getSerializer("",ShipmentResultReturn2.class, new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")).writeSchema(ShipmentResultReturn2.class,Types.getPackageNameFromFullName("http://www.w3.org/2001/XMLSchema"))));
    		//shipment2.getSerializer("", _javaType, _xmlType)
    		
    		OutputStream file = new FileOutputStream( "D:"+File.separator+"wmstest.ser" );
    	    OutputStream buffer = new BufferedOutputStream( file );
    	    ObjectOutput output = new ObjectOutputStream( buffer );
   	        output.writeObject(shipment2);
   	        output.flush();
   	        output.close();
   	        
   	        
	   	     InputStream file1 = new FileInputStream( "D:"+File.separator+"wmstest.ser" );
	         InputStream buffer1 = new BufferedInputStream( file1 );
	         ObjectInput input = new ObjectInputStream ( buffer1 );
	         Shipment2 testShipment = (Shipment2)input.readObject();
        	 System.out.println("Class Deserializer"+testShipment.getServiceName());
        	 System.out.println("Class Deserializer"+testShipment.getShipperName());
        	 Package2[] pack2test = testShipment.getPackages2();
        	 
        	 for(int i=0;i<pack2test.length;i++)
        	 {
        		 System.out.println("Packages"+pack2test[i].getWeight());
        	 }*/
        	 
        	/*	System.out.println("Symbol--------------------- ["+objShipResult.getServiceSymbol());
        		System.out.println("Plain Text--------------------- ["+objShipResult.getServicePlaintext());
        		//System.out.println("response12 ["+soap.getServices());
        		System.out.println("response3-------------------- ["+soap.getCarrierSymbolsList().getResponseList()[5]+"]");
        		System.out.println("Service Plain text["+objShipResult.getServicePlaintext()+"]");
        		System.out.println("MSN ID["+objShipResult.getPackageResults2()[0].getMSN()+"]");
            	
        		StringReturn testReturn = soap.voidPackage("TANDATA_UPS.UPS",objShipResult.getPackageResults2()[0].getMSN());
        		
	         	//StringReturn testReturn = soap.voidPackage("TANDATA_UPS.UPS",objShipResult.getPackageResults2()[0].getMSN());
             	Carrier[] carr = soap.getCarriers().getCarrierList();
             	String carrierSymbol = "";
             	
             	for(int j = 0;j<carr.length;j++)
             	{
             		Carrier carr1 = carr[j];
             		System.out.println("Carrier Symbol["+carr1.getSymbol());
             		System.out.println("Friendly Name["+carr1.getFriendlyName());
             		System.out.println("Short Name["+carr1.getShortName());

             	}
             	
             	System.out.println("MSN NO------------------------------------------------------["+objShipResult.getPackageResults2()[0].getMSN()+"]");
             	
             	String[] carrierFriendly = soap.getCarrierFriendlyNamesList().getResponseList();
             	
             	for(int k = 0;k<carrierFriendly.length;k++)
             	{
             	
             		System.out.println("Carrier Friendly Name List ["+carrierFriendly[k]);
             	

             	}
             	
             	Service[] ser = soap.getServices().getServiceList();
             	
             	for(int M = 0;M<carrierFriendly.length;M++)
             	{
             		
             		Service srvtest = ser[M];
             		System.out.println("Friendly Name ["+srvtest.getFriendlyName());
             		System.out.println("get Symbol ["+srvtest.getSymbol());
             	

             	}
             	
             	
             	NameValuePair[] nameval1 =  objShipResult.getAdditionalFields();
             	
             	
             	for(int L = 0;L<nameval1.length;L++)
             	{
             		
             		
             		System.out.println(" Name1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>["+nameval1[L].getName());
             		System.out.println(" vALUE1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>["+nameval1[L].getValue());
             	

             	}
        		      	 
             	
             	NameValuePair[] nameval =  objShipResult.getPackageResults2()[0].getAdditionalFields();
             	
             	
             	for(int L = 0;L<nameval.length;L++)
             	{
             		
             		
             		System.out.println(" Name ------------------------------------------------["+nameval[L].getName());
             		System.out.println(" vALUE -----------------------------------------------["+nameval[L].getValue());
             	

             	}
             	
             	
        		//String response =  testReturn.getResponse();
        		//System.out.println("response ["+response+"]");
        	 
        	//System.out.println("Data void return ["+soap.voidPackage(objShipResult.getServiceSymbol(),objShipResult.getPackageResults2()[0].getMSN())+"]");
	         while (input.available() != -1) {
	                //Read object from file
	        	 Shipment testShipment = (Shipment)input.readObject();
	        	 System.out.println("Class Deserializer"+testShipment.getServiceName());
	            }
	        
        	 //testShipment.getP
      
             	String value = objShipResult.getPackageResults2()[0].getBase64Label();
        		BASE64Decoder decoder = new BASE64Decoder();  
				byte[] imgBytes = decoder.decodeBuffer(value);    
				System.out.println("IMAGE Byte Length ["+imgBytes.length+"]");
				BufferedImage bufImg = ImageIO.read(new ByteArrayInputStream(imgBytes));  
				//D:\jboss-5.1.0.GA\server\default\deploy\ibase.ear\ibase.war\webitm\reports\ADSI
				File imgOutFile = new File("D:"+File.separator+"test_img.png");
				//File imgOutFile = new File(CommonConstants.JBOSSHOME+File.separator+"server"+File.separator+"default"+File.separator+"deploy"+File.separator+"ibase.ear"+File.separator+"ibase.war"+File.separator+"webitm"+File.separator+"reports" + File.separator + "ADSI" + File.separator + ptcn +".png");
			
				imgOutFile.createNewFile();
				ImageIO.write(bufImg, "png", imgOutFile);
								
				System.out.println("Close Out Date["+shipment2.getShipDate().getTime().toLocaleString()+"]");
				
				StringDictionaryReturn testStr = soap.closeOutEOD("Taro Commercial", "FedEx Ground®","6/17/2013", false, "");
    		
				System.out.println("Message for Close Oute["+testStr.getMessage()+"]");
				System.out.println("Message for Close Oute["+testStr.getResponseDictionary().toString()+"]");
				NameValuePair[] nameval =  objShipResult.getPackageResults2()[0].getAdditionalFields();
             	
             	
             	for(int L = 0;L<nameval.length;L++)
             	{
             		
             		
             		System.out.println(" Name ------------------------------------------------["+nameval[L].getName());
             		System.out.println(" vALUE -----------------------------------------------["+nameval[L].getValue());

             	}
             	*/             	
             /*	StringListReturn strCloseList = soap.getCloseOutList("Taro Commercial", "UPS (US)");
             	
             	System.out.println("strCloseList["+strCloseList.getMessage()+"]");*/
             	
             /*	
             	if(strCloseList.getResponseList() != null)
             		
             	{
             		//System.out.println("strCloseList["+strCloseList.getResponseList()[0]+"]");
             	
             	       	
            	
	             	for(int r = 0;r<strCloseList.getResponseList().length;r++)
	             	{
	             		
	             		
	             		System.out.println(" strCloseList.getResponseList() UPS US--["+strCloseList.getResponseList()[r]+"]---FEDGND");
	             	
	
	             	}
	             	
	             	SimpleDateFormat format = new SimpleDateFormat("M/d/yyyy");
	             	
	             	String strSmple = format.format(calendar.getTime());
	             	System.out.println("strSmple["+strSmple+"]");
             	}*/
             	
             	
             /*	StringListReturn strCloseList1 = soap.getCloseOutList("Taro Commercial", "FedEx Ground®");
             	
             	System.out.println("strCloseLisDEXt FE["+strCloseList1.getMessage()+"]");
             	
             	
             	if(strCloseList1.getResponseList() != null)
             		
             	{
             		//System.out.println("strCloseList["+strCloseList.getResponseList()[0]+"]");
             	
             	       	
            	
	             	for(int r = 0;r<strCloseList1.getResponseList().length;r++)
	             	{
	             		
	             		
	             		System.out.println(" strCloseList.getResponseList() FedEx Ground®--["+strCloseList1.getResponseList()[r]+"]---FEDGND");
	             	
	
	             	}
	             	
	             	
             	}*/
	
				//StringDictionaryReturn testStr = soap.closeOutEOD("Taro Commercial", "FedEx Ground®",strSmple, true, "Shipments");
             	/*StringDictionaryReturn testStr = soap.closeOutEOD("Taro Commercial", "UPS (US)","6/29/13", true, "Shipments");
	    		
				System.out.println("Message for Close Out["+testStr.getMessage()+"]");
				System.out.println("isSuccess["+testStr.isSuccess()+"]");
				
				System.out.println("TEST ["+(testStr.getResponseDictionary().get_any() == null)+"]");
				
				int len1 = testStr.getResponseDictionary().get_any().length;
				for(int cCTR =0 ;cCTR <len1;cCTR++)
				{
					//testStr.getResponseDictionary().
					System.out.println("Name["+testStr.getResponseDictionary().get_any()[cCTR]);
					System.out.println("Name["+testStr.getResponseDictionary().get_any()[cCTR].getNodeName());
					System.out.println("Value["+testStr.getResponseDictionary().get_any()[cCTR].getNodeValue());
					System.out.println("Name["+testStr.getResponseDictionary().get_any()[cCTR].getNodeName());
					//System.out.println("Child Elements["+testStr.getResponseDictionary().get_any()[cCTR].getChildElements().next().toString());
					if(testStr.getResponseDictionary().get_any()[cCTR].getElementsByTagName("string").item(0).getFirstChild() != null)
					{
						System.out.println("Column Name["+testStr.getResponseDictionary().get_any()[cCTR].getElementsByTagName("string").item(0).getFirstChild().getNodeValue()+"]");
					}
					
					if(testStr.getResponseDictionary().get_any()[cCTR].getElementsByTagName("string").item(1).getFirstChild() != null)
					{
						System.out.println("Value["+testStr.getResponseDictionary().get_any()[cCTR].getElementsByTagName("string").item(1).getFirstChild().getNodeValue()+"]");
					}
					//d3b1303f-9d94-48af-8850-6943adfd592b
					//9f691b38-7edf-4016-9591-3ded13a6bac9
				}*/
        	 	PackageResult2 pkg2frm =  (PackageResult2)objShipResult.getPackageResults2()[0];

        	 	System.out.println("Current MSN No----["+pkg2frm.getMSN()+"]");
             	
             	Package2[] packages2Test = shipment2.getPackages2(); 
             	Package2[] packages2List =  new Package2[packages2Test.length + 2];
             	packages2List[0] =  shipment2.getPackages2()[0];
             	Package2 pkg = shipment2.getPackages2()[0];
             	pkg.setID("123456888888");
             	packages2List[1] =  pkg;
             	shipment2.setPackages2(packages2List);
            	ShipmentResultReturn2 objReturn3 = soap.shipWithLabel(shipment2, labelType, imageRotation);
            	ShipmentResult2 objShipResult1 = objReturn3.getShipmentResultResponse2();
            	PackageResult2 pkg2frm1 =  (PackageResult2)objShipResult1.getPackageResults2()[0];
            	System.out.println("Changed MSN No["+pkg2frm1.getMSN()+"]---");
            	PackageResult2 pkg2frm2 =  (PackageResult2)objShipResult1.getPackageResults2()[1];
            	System.out.println("Changed MSN No2["+pkg2frm2.getMSN()+"]---");
            	StringReturn testReturn = soap.voidPackage("TANDATA_UPS.UPS",pkg2frm1.getMSN());
            	System.out.println("Response voiding["+testReturn.getResponse()+"]");
            	
            	for(int Cadd=0;Cadd<pkg2frm.getAdditionalFields().length;Cadd++)
				{
					System.out.println("additional fields are Name:"+pkg2frm.getAdditionalFields()[Cadd].getName());
					System.out.println("additional fields are Value:"+pkg2frm.getAdditionalFields()[Cadd].getValue());
				}
            	BASE64Decoder decoder = new BASE64Decoder();  
            	System.out.println("Response voiding["+pkg2frm.getPackageID()+"]");
            	System.out.println("Package id for carton no is :[" +decoder.decodeBuffer(pkg2frm.getPackageID()) +"]");
    		
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
    }

}
