Background
This example uses the StrikeIron Address Verification web service to validate an address.
The SOAP request is constructed in JavaScript based on the WSDL for this web service. nlapiRequestURL is used
to make the external callout and the return values are extracted from the SOAP-formatted XML response using some
of the built-in XPath SuiteScript functions.
SOAP Protocol
Sample Request (SOAP Interface)
Address: 2955 Campus Dr, Suite 175, San Mateo, CA, 94403
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding"> <soap:Header> <s1:LicenseInfo xmlns:s1="http://ws.strikeiron.com"> <s1:RegisteredUser> <s1:UserID>USER_NAME_HERE</s1:UserID> <s1:Password>*****</s1:Password> </s1:RegisteredUser> </s1:LicenseInfo> </soap:Header> <soap:Body> <si:VerifyAddressUSA xmlns:si="http://www.strikeiron.com"> <si:addressLine1>2955 Campus Dr</si:addressLine1> <si:addressLine2>Suite 175</si:addressLine2> <si:city_state_zip>San Mateo, CA, 94403</si:city_state_zip> </si:VerifyAddressUSA> </soap:Body> </soap:Envelope>
Sample Response (SOAP Interface) <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Header> <ResponseInfo xmlns="http://www.strikeiron.com"> <ResponseCode>0</ResponseCode> <Response>Success</Response> </ResponseInfo> <SubscriptionInfo xmlns="http://ws.strikeiron.com"> <LicenseStatusCode>0</LicenseStatusCode> <LicenseStatus>Valid license key</LicenseStatus> <LicenseActionCode>0</LicenseActionCode> <LicenseAction>Decremented hit count</LicenseAction> <RemainingHits>23</RemainingHits> <Amount>0</Amount> </SubscriptionInfo> </soap:Header> <soap:Body> <VerifyAddressUSAResponse xmlns="http://www.strikeiron.com"> <VerifyAddressUSAResult> <AddressLine1>2955 CAMPUS DR STE 175</AddressLine1> <AddressLine2/> <StreetNumber>2955</StreetNumber> <Firm/> <PreDirection/> <StreetName>CAMPUS</StreetName> <StreetType>DR</StreetType> <PostDirection/> <Extension>STE</Extension> <ExtensionNumber>175</ExtensionNumber> <Village/> <City>SAN MATEO</City> <AddressStatus>VALID</AddressStatus> <AddressErrorNumber>0</AddressErrorNumber> <AddressErrorMessage/> <State>CA</State> <Urbanization/> <ZipPlus4>94403-2511</ZipPlus4> <Zip>94403</Zip> <ZipAddOn>2511</ZipAddOn> <CarrierRoute>C031</CarrierRoute> <PMB/> <PMBDesignator/> <DeliveryPoint>25</DeliveryPoint> <DPCheckDigit>4</DPCheckDigit> <LACS/> <CMRA>N</CMRA> <DPV>Y</DPV> <DPVFootnote>AA BB</DPVFootnote> <RDI/> <RecordType>H</RecordType> <CongressDistrict>12</CongressDistrict> <County>SAN MATEO</County> <CountyNumber>81</CountyNumber> <StateNumber>6</StateNumber> <GeoCode> <Latitude>37.536756</Latitude> <Longitude>-122.3284</Longitude> <CensusTract>606700</CensusTract> <StateNumber>06</StateNumber> <CountyNumber>081</CountyNumber> <BlockNumber>2000</BlockNumber> <BlockGroup>060816067002</BlockGroup> </GeoCode> </VerifyAddressUSAResult> </VerifyAddressUSAResponse> </soap:Body> </soap:Envelope>
Script function validateAddressUsingStrikeIronServiceCall( ) { /* service URL for US address verification web service. */ var strikeIronServiceUrl = 'http://ws.strikeiron.com/StrikeIron/USAddressVerification4_0/USAddressVerification'; var address1 = '2955 Campus Drive'; var address2 = 'Suite 175'; var city = 'San Mateo'; var state = 'CA'; var zip = '94403'; var citystatezip = city != null ? city : ''; citystatezip = citystatezip.length > 0 && state != null ? citystatezip + ', ' + state : state != null ? state : citystatezip; citystatezip = citystatezip.length > 0 && zip != null ? citystatezip + ', ' + zip : zip != null ? zip : citystatezip; var username = ''; /* Enter StrikeIron username or license code here. */ var password = ''; /* Enter StrikeIron password here if using username. */ var response = null; var serviceUrl = strikeIronServiceUrl; var licenseinfo = wrapSoapLicenseHeader( username, password ); var addressinfo = wrapSoapAddressBody( address1, address2, citystatezip ); var soapPayload = wrapPayload( licenseinfo + addressinfo ); var soapHeaders = new Array(); /* Add required SOAP header indicating the intent of this service call. */ soapHeaders['SOAPAction'] = '