Hi,
I have created a class library for USPS integration, which works good and performs its task accordingly.
Then I have added the reference to this dll into AX client and writes a job which sets and gets the value from that library. The issue is while I am getting values from .net library the returned values are of type System.String, I get these values in variables of type System.String and tried to marshal them into X++ string type. But it shows error during marshalling. Though this is very basic code,the part which is causing trouble is in bold and at the end of the code.
static void AddressVerification(Args _args)
{
CodeAccessPermission permission;
//USPS.USPS_AV AV;
AddressVerificationClassLibrary.USPS_AddressVerification AV;
LogisticsAddressStreet AX_Street;
LogisticsAddressCity AX_City;
LogisticsAddressCountyId AX_County;
LogisticsAddressStateId AX_State;
LogisticsAddressCountryRegionId AX_Country;
LogisticsAddressZipCodeId AX_Zip;
System.String USPS_Address1;
System.String USPS_Address2;
System.String USPS_City;
System.String USPS_State;
System.String USPS_Zip5;
System.String USPS_Zip4;
str strUSPS_Address1;
str strUSPS_Address2;
str strUSPS_City;
str strUSPS_State;
str strUSPS_Zip5;
str strUSPS_Zip4;
boolean result = false;
permission = new InteropPermission(InteropKind::CLRInterop);
permission.assert();
AV = new AddressVerificationClassLibrary.USPS_AddressVerification();
AX_Street = "6406 Ivy Lane"
AX_City = "Greenbelt";
AX_County = "";
AX_State = "MD";
AX_Country = "";
AX_Zip = "";
AV.set_AXStreet(AX_Street);
AV.set_AXCity(AX_City);
AV.set_AXCounty(AX_County);
AV.set_AXState(AX_State);
AV.set_AXCountry(AX_Country);
AV.set_AXZip(AX_Zip);
AV.validate();
//result = AV.get_Result();
USPS_Address1 = AV.get_USPSAddress1();
USPS_Address2 = AV.get_USPSAddress2();
USPS_City = AV.get_USPSCity();
USPS_State = AV.get_USPSState();
USPS_Zip5 = AV.get_USPSZip5();
USPS_Zip4 = AV.get_USPSZip4();
strUSPS_Address1 = USPS_Address1.ToString();
strUSPS_Address2 = USPS_Address2.ToString();
strUSPS_City = USPS_City.ToString();
strUSPS_State = USPS_State.ToString();
strUSPS_Zip5 = USPS_Zip5.ToString();
strUSPS_Zip4 = USPS_Zip4.ToString();
}
}
Rishi