+ Start a Discussion
vviyervviyer 

Call out to external webservice

I'm learning to write apex code for calling out to external webservices. I started out with strikeIrons zipcode lookup. I'm new to webservices, so please help me out. Is this how I should go abt doing it?

1. Get WSDL. Generate apex.(done)

2. Created county__c field in account sObject(done)

3. Write before insert, before update trigger that passes the zipcode to CountyLookupClass.(done)

4. CountyLookupClass calls the @future webservice, passes the authentication parameters(username,password) and also the zipcode. 

5. StrikeIron authenticates. Returns county. 

6. Need to map the returned county name to Account.County__c field, so that it is added/inserted to the force.com database. 

 

Am I right? Here is the trigger

 

trigger CountyLookupTrigger on Account (before insert, before update) {

for(Account a: Trigger.new)
CountyLookupClass.CallWS(a);

}

 

 Apex class in invoke webservice

 

public class CountyLookupClass {


@future(callout=true)
public static void CallWS(String zcode){
//pass zipcode to ZipINfo
//get info
//parse to county__c
//create the stub
ZipLookup.ZipInfoSoap zipl = new ZipLookup.ZipInfoSoap();

//instantiate and setup authentication information

zipl.LicenseInfo = new ZipUser.LicenseInfo();
zipl.LicenseInfo.RegisteredUser = new ZipUser.RegisteredUser();
zipl.LicenseInfo.RegisteredUser.UserID = 'withoutme@gmail.com';
zipl.LicenseInfo.RegisteredUser.Password='******';
//call web service
ZipLookup.SIWsOutputOfZipInfoResult zz = zipl.GetCityState('94131');
String c = zz.ServiceResult.Code;
System.debug('Codeis' + c);
//ZipLookup.ZipInfoResult z = zipl.GetCityState('85281').;

}}

 

 

 

 

How do I test this? Am I doing it right?

 

 

 

And the apex from wsdl2apex.wsdl fom http://www.strikeiron.com/productdetail.aspx?p=436

 

 


 

Message Edited by vviyer on 04-09-2009 10:33 PM
Message Edited by vviyer on 04-09-2009 11:44 PM
Message Edited by vviyer on 04-09-2009 11:45 PM
Ron HessRon Hess

your @future class must be passed a string not an Account object

 

so, i suggest you pass the account ID (as a string)

 

then in  the CallWS method, you must query the account object to get it's zip code,

then make the callout, then store the result and call update on that account.

 

you must debug this by adding system.debug statements and then creating and reviewing a debug log

using the monitoring / Debug Logs  feature found under Administration setup.

vviyervviyer

Ron,

I made the following changes as per ur suggestion. I'm confused as to where to parse the response from. SO many classes.

Here is my trigger class

 

public class CountyLookupClass {


@future(callout=true)
public static void CallWS(Set<String> actIds){


//Creating a Map witih ID and zipcodes with a SOQL query using actIds
Map<Id,Account> actmap = new Map<Id,Account>([select Account.BillingPostalCode, Account.County__c from Account where Id in:actIds]);
System.debug('The ID is:::'+ actIds);
System.debug('The soql result is:::' + actmap);
//iterate thru the ids
for(ID i: actIds){
Account a = actmap.get(i);
//create an instance of the zipplookup service
ZipLookup.ZipInfoSoap zip = new ZipLookup.ZipInfoSoap();

//instantiate and setup authentication information

zip.LicenseInfo = new ZipUser.LicenseInfo();
zip.LicenseInfo.RegisteredUser = new ZipUser.RegisteredUser();
zip.LicenseInfo.RegisteredUser.UserID = 'withoutme@gmail.com';
zip.LicenseInfo.RegisteredUser.Password='vijayv';

//call web service
ZipLookup.SIWsOutputOfZipInfoResult info = zip.GetCityState(a.BillingPostalCode);
System.debug('the info retreived::::'+ info);
//String x = zipl.GetCityState(zcode).GetCityStateResult
// System.debug('calling.. ' + zcode);
//zipl.GetCityState(zcode);
//ZipLookup.SIWsOutputOfZipInfoResult zz = zipl.GetCityState(zcode);
//System.debug('Returned from ws call');
//String c = zz.ServiceResult.Code;
//System.debug('Codeis' + c);
//ZipLookup.ZipInfoResult z = zipl.GetCityState('85281');
}
}
}

trigger LookupCounty on Account (after insert, after update) {

Set<String> aID = new Set<String>();
for(Account a: Trigger.new)
aID.add(a.Id);
CountyLookupClass.CallWS(aID);
}

 The wsdl2apex generated two classes. ZipLookup and ZipUser(my naming). The ZipLookup is where the actual callout is made, and the response is parsed. Please help me with the parsing of the response. The ZipLookup clas is in th next msg

 

20090410202424.939:Class.CountyLookupClass.CallWS: line 10, column 9: The ID is:::{0018000000Q7XJNAA3} 20090410202424.939:Class.CountyLookupClass.CallWS: line 11, column 9: The soql result is:::{0018000000Q7XJNAA3=Account:{BillingPostalCode=85281, Id=0018000000Q7XJNAA3}} System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element http://www.strikeiron.com=Results Class.ZipLookup.ZipInfoSoap.GetCityState: line 227, column 13 Class.CountyLookupClass.CallWS: line 26, column 56

 

 

 

 

Message Edited by vviyer on 04-10-2009 01:02 PM
Message Edited by vviyer on 04-10-2009 01:27 PM
vviyervviyer

public class ZipLookup { public class ZipInfoListing { public String CityName; public String PreferredName; public String StateAbbreviation; public String Classification; public String County; private String[] CityName_type_info = new String[]{'CityName','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] PreferredName_type_info = new String[]{'PreferredName','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] StateAbbreviation_type_info = new String[]{'StateAbbreviation','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] Classification_type_info = new String[]{'Classification','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] County_type_info = new String[]{'County','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'CityName','PreferredName','StateAbbreviation','Classification','County'}; } public class MethodStatusRecord { public String MethodName; private String[] MethodName_type_info = new String[]{'MethodName','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'MethodName'}; } public class GetStatusCodes_element { private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{}; } public class SIWsStatus { public Integer StatusNbr; public String StatusDescription; private String[] StatusNbr_type_info = new String[]{'StatusNbr','http://www.w3.org/2001/XMLSchema','int','1','1','false'}; private String[] StatusDescription_type_info = new String[]{'StatusDescription','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'StatusNbr','StatusDescription'}; } public class SIWsOutputOfSIWsResultArrayOfMethodStatusRecord { public ZipLookup.SIWsStatus ServiceStatus; public ZipLookup.SIWsResultArrayOfMethodStatusRecord ServiceResult; private String[] ServiceStatus_type_info = new String[]{'ServiceStatus','http://www.strikeiron.com','SIWsStatus','0','1','false'}; private String[] ServiceResult_type_info = new String[]{'ServiceResult','http://www.strikeiron.com','SIWsResultArrayOfMethodStatusRecord','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'ServiceStatus','ServiceResult'}; } public class GetCityState_element { public String ZIPCode; private String[] ZIPCode_type_info = new String[]{'ZIPCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'ZIPCode'}; } public class ServiceInfoRecord { public String InfoKey; public String InfoValue; private String[] InfoKey_type_info = new String[]{'InfoKey','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] InfoValue_type_info = new String[]{'InfoValue','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'InfoKey','InfoValue'}; } public class GetStatusCodesResponse_element { public ZipLookup.SIWsOutputOfSIWsResultArrayOfMethodStatusRecord GetStatusCodesResult; private String[] GetStatusCodesResult_type_info = new String[]{'GetStatusCodesResult','http://www.strikeiron.com','SIWsOutputOfSIWsResultArrayOfMethodStatusRecord','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'GetStatusCodesResult'}; } public class ArrayOfSIWsStatus { public ZipLookup.SIWsStatus[] SIWsStatus; private String[] SIWsStatus_type_info = new String[]{'SIWsStatus','http://www.strikeiron.com','SIWsStatus','0','-1','true'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'SIWsStatus'}; } public class GetStatusCodesForMethodResponse_element { public ZipLookup.SIWsOutputOfMethodStatusRecord GetStatusCodesForMethodResult; private String[] GetStatusCodesForMethodResult_type_info = new String[]{'GetStatusCodesForMethodResult','http://www.strikeiron.com','SIWsOutputOfMethodStatusRecord','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'GetStatusCodesForMethodResult'}; } public class GetServiceInfo_element { private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{}; } public class SIWsOutputOfMethodStatusRecord { public ZipLookup.SIWsStatus ServiceStatus; public ZipLookup.MethodStatusRecord ServiceResult; private String[] ServiceStatus_type_info = new String[]{'ServiceStatus','http://www.strikeiron.com','SIWsStatus','0','1','false'}; private String[] ServiceResult_type_info = new String[]{'ServiceResult','http://www.strikeiron.com','MethodStatusRecord','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'ServiceStatus','ServiceResult'}; } public class ZipInfoResult { public String Code; public String Latitude; public String Longitude; public String TimeZone; public String StandardGMTOffset; public String DaylightGMTOffset; private String[] Code_type_info = new String[]{'Code','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] Latitude_type_info = new String[]{'Latitude','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] Longitude_type_info = new String[]{'Longitude','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] TimeZone_type_info = new String[]{'TimeZone','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] StandardGMTOffset_type_info = new String[]{'StandardGMTOffset','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] DaylightGMTOffset_type_info = new String[]{'DaylightGMTOffset','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'Code','Latitude','Longitude','TimeZone','StandardGMTOffset','DaylightGMTOffset'}; } public class SIWsResultArrayOfSIWsStatus { public ZipLookup.ArrayOfSIWsStatus Results; private String[] Results_type_info = new String[]{'Results','http://www.strikeiron.com','ArrayOfSIWsStatus','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'Results'}; } public class ArrayOfMethodStatusRecord { public ZipLookup.MethodStatusRecord[] MethodStatusRecord; private String[] MethodStatusRecord_type_info = new String[]{'MethodStatusRecord','http://www.strikeiron.com','MethodStatusRecord','0','-1','true'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'MethodStatusRecord'}; } public class GetCityStateResponse_element { public ZipLookup.SIWsOutputOfZipInfoResult GetCityStateResult; private String[] GetCityStateResult_type_info = new String[]{'GetCityStateResult','http://www.strikeiron.com','SIWsOutputOfZipInfoResult','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'GetCityStateResult'}; } public class ArrayOfZipInfoListing { public ZipLookup.ZipInfoListing[] ZipInfoListing; private String[] ZipInfoListing_type_info = new String[]{'ZipInfoListing','http://www.strikeiron.com','ZipInfoListing','0','-1','true'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'ZipInfoListing'}; } public class SIWsResultArrayOfMethodStatusRecord { public ZipLookup.ArrayOfMethodStatusRecord Results; private String[] Results_type_info = new String[]{'Results','http://www.strikeiron.com','ArrayOfMethodStatusRecord','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'Results'}; } public class SIWsResultArrayOfServiceInfoRecord { public ZipLookup.ArrayOfServiceInfoRecord Results; private String[] Results_type_info = new String[]{'Results','http://www.strikeiron.com','ArrayOfServiceInfoRecord','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'Results'}; } public class SIWsOutputOfZipInfoResult { public ZipLookup.SIWsStatus ServiceStatus; public ZipLookup.ZipInfoResult ServiceResult; private String[] ServiceStatus_type_info = new String[]{'ServiceStatus','http://www.strikeiron.com','SIWsStatus','0','1','false'}; private String[] ServiceResult_type_info = new String[]{'ServiceResult','http://www.strikeiron.com','ZipInfoResult','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'ServiceStatus','ServiceResult'}; } public class SIWsResultArrayOfZipInfoListing { public ZipLookup.ArrayOfZipInfoListing Results; private String[] Results_type_info = new String[]{'Results','http://www.strikeiron.com','ArrayOfZipInfoListing','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'Results'}; } public class ArrayOfServiceInfoRecord { public ZipLookup.ServiceInfoRecord[] ServiceInfoRecord; private String[] ServiceInfoRecord_type_info = new String[]{'ServiceInfoRecord','http://www.strikeiron.com','ServiceInfoRecord','0','-1','true'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'ServiceInfoRecord'}; } public class SIWsOutputOfSIWsResultArrayOfServiceInfoRecord { public ZipLookup.SIWsStatus ServiceStatus; public ZipLookup.SIWsResultArrayOfServiceInfoRecord ServiceResult; private String[] ServiceStatus_type_info = new String[]{'ServiceStatus','http://www.strikeiron.com','SIWsStatus','0','1','false'}; private String[] ServiceResult_type_info = new String[]{'ServiceResult','http://www.strikeiron.com','SIWsResultArrayOfServiceInfoRecord','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'ServiceStatus','ServiceResult'}; } public class ZipInfoSoap { public String endpoint_x = 'http://ws.strikeiron.com/StrikeIron/ZIPInfo4/ZipInfo'; public Map<String,String> inputHttpHeaders_x; public Map<String,String> outputHttpHeaders_x; public String clientCert_x; public String clientCertPasswd_x; public Integer timeout_x; public ZipUser.SubscriptionInfo SubscriptionInfo; public ZipUser.LicenseInfo LicenseInfo; private String SubscriptionInfo_hns = 'SubscriptionInfo=http://ws.strikeiron.com'; private String LicenseInfo_hns = 'LicenseInfo=http://ws.strikeiron.com'; private String[] ns_map_type_info = new String[]{'http://www.strikeiron.com', 'ZipLookup', 'http://ws.strikeiron.com', 'ZipUser'}; public ZipLookup.SIWsOutputOfMethodStatusRecord GetStatusCodesForMethod(String MethodName) { ZipLookup.GetStatusCodesForMethod_element request_x = new ZipLookup.GetStatusCodesForMethod_element(); ZipLookup.GetStatusCodesForMethodResponse_element response_x; request_x.MethodName = MethodName; Map<String, ZipLookup.GetStatusCodesForMethodResponse_element> response_map_x = new Map<String, ZipLookup.GetStatusCodesForMethodResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://www.strikeiron.com/GetStatusCodesForMethod', 'http://www.strikeiron.com', 'GetStatusCodesForMethod', 'http://www.strikeiron.com', 'GetStatusCodesForMethodResponse', 'ZipLookup.GetStatusCodesForMethodResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.GetStatusCodesForMethodResult; } public ZipLookup.SIWsOutputOfSIWsResultArrayOfServiceInfoRecord GetServiceInfo() { ZipLookup.GetServiceInfo_element request_x = new ZipLookup.GetServiceInfo_element(); ZipLookup.GetServiceInfoResponse_element response_x; Map<String, ZipLookup.GetServiceInfoResponse_element> response_map_x = new Map<String, ZipLookup.GetServiceInfoResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://www.strikeiron.com/GetServiceInfo', 'http://www.strikeiron.com', 'GetServiceInfo', 'http://www.strikeiron.com', 'GetServiceInfoResponse', 'ZipLookup.GetServiceInfoResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.GetServiceInfoResult; } public ZipLookup.SIWsOutputOfZipInfoResult GetCityState(String ZIPCode) { ZipLookup.GetCityState_element request_x = new ZipLookup.GetCityState_element(); ZipLookup.GetCityStateResponse_element response_x; request_x.ZIPCode = ZIPCode; Map<String, ZipLookup.GetCityStateResponse_element> response_map_x = new Map<String, ZipLookup.GetCityStateResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://www.strikeiron.com/GetCityState', 'http://www.strikeiron.com', 'GetCityState', 'http://www.strikeiron.com', 'GetCityStateResponse', 'ZipLookup.GetCityStateResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.GetCityStateResult; } public void GetRemainingHits() { ZipUser.GetRemainingHits_element request_x = new ZipUser.GetRemainingHits_element(); ZipUser.GetRemainingHitsResponse_element response_x; Map<String, ZipUser.GetRemainingHitsResponse_element> response_map_x = new Map<String, ZipUser.GetRemainingHitsResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://ws.strikeiron.com/StrikeIron/ZIPInfo4/ZipInfo/GetRemainingHits', 'http://ws.strikeiron.com', 'GetRemainingHits', 'http://ws.strikeiron.com', 'GetRemainingHitsResponse', 'ZipUser.GetRemainingHitsResponse_element'} ); response_x = response_map_x.get('response_x'); } public ZipLookup.SIWsOutputOfSIWsResultArrayOfMethodStatusRecord GetStatusCodes() { ZipLookup.GetStatusCodes_element request_x = new ZipLookup.GetStatusCodes_element(); ZipLookup.GetStatusCodesResponse_element response_x; Map<String, ZipLookup.GetStatusCodesResponse_element> response_map_x = new Map<String, ZipLookup.GetStatusCodesResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://www.strikeiron.com/GetStatusCodes', 'http://www.strikeiron.com', 'GetStatusCodes', 'http://www.strikeiron.com', 'GetStatusCodesResponse', 'ZipLookup.GetStatusCodesResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.GetStatusCodesResult; } } public class GetStatusCodesForMethod_element { public String MethodName; private String[] MethodName_type_info = new String[]{'MethodName','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'MethodName'}; } public class GetServiceInfoResponse_element { public ZipLookup.SIWsOutputOfSIWsResultArrayOfServiceInfoRecord GetServiceInfoResult; private String[] GetServiceInfoResult_type_info = new String[]{'GetServiceInfoResult','http://www.strikeiron.com','SIWsOutputOfSIWsResultArrayOfServiceInfoRecord','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true','false'}; private String[] field_order_type_info = new String[]{'GetServiceInfoResult'}; } }

 

Ron HessRon Hess

looks like you are getting an error message from the webservice module that is suposed to parse the response.

 

not much you can do , since that module is not documented.

 

did you enable this endpoint in the remote site settings for this org ?

 

can you turn on the soap response debug info in the system log ?

 

or , if that does not work you can construct the SOAP using strings, and send it with HTTP.send() .  This gives your code more control of how the response is parsed.

 

Ron HessRon Hess

looks like this complex return type is not supported

 

please see this thread for one idea to update the WSDL.

 

http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=7486

 

 

 

vviyervviyer

I have included strikeiron.com and ws.strikeiron.com in the remote iste setttings.

when u say, enable soap responsein the system log, do u mean setting the log category to "callout" in the system log. in that case. the log(not much info) isi

14:18:55 DEBUG - *** Beginning LookupCounty on Account trigger event AfterUpdate for 0018000000Q7XJN 20090410211854.534:Trigger.LookupCounty: line 1, column 1: TriggerBody: LookupCounty 20090410211854.534:Trigger.LookupCounty: line 3, column 9: DeclareVar: SET:String aID 20090410211854.534:Trigger.LookupCounty: line 3, column 9: initial value: {} 20090410211854.534:Trigger.LookupCounty: line 4, column 5: SelectLoop:LIST:SOBJECT:Account 20090410211854.534:Trigger.LookupCounty: line 5, column 9: SET:String.add(Id) 20090410211854.534:Trigger.LookupCounty: line 6, column 6: System.debug(String) 20090410211854.534:Trigger.LookupCounty: line 6, column 6: act0018000000Q7XJNAA3 20090410211854.534:Trigger.LookupCounty: line 8, column 5: CountyLookupClass.CallWS(SET:String) Cumulative resource usage: Resource usage for namespace: (default) Number of SOQL queries: 0 out of 20 Number of query rows: 0 out of 1000 Number of SOSL queries: 0 out of 0 Number of DML statements: 0 out of 20 Number of DML rows: 0 out of 100 Number of script statements: 4 out of 10200 Maximum heap size: 0 out of 100000 Number of callouts: 0 out of 10 Number of Email Invocations: 0 out of 10 Number of fields describes: 0 out of 10 Number of record type describes: 0 out of 10 Number of child relationships describes: 0 out of 10 Number of picklist describes: 0 out of 10 Number of future calls: 1 out of 10 Number of find similar calls: 0 out of 0 Number of System.runAs() invocations: 0 out of 0 Total email recipients queued to be sent : 0 Static variables and sizes: LookupCounty:aID:26 *** Ending LookupCounty on Account trigger event AfterUpdate for 0018000000Q7XJN Cumulative profiling information: No profiling information for SOQL operations. No profiling information for SOSL operations. No profiling information for DML operations. 

 

 

 

vviyervviyer
I will try to pull the extension of the complex type into a child object and isee if it works. I'm working on a similar class for DNS Lookup. In this case, the Calloout is a success. But I'm having difficulty, in actually parsing to the right variable in the class to get JUST the IP address out. This is from the language reference http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_web_services_wsdl2apex.htm#invoking_callout

public class DNSLookupClass{ @future(callout=true) public static void callDNS(String address){ // Create the stub tempuriOrg.DNSSoap dns = new tempuriOrg.DNSSoap(); // Set up the license header dns.LicenseInfo = new wsStrikeironCom.LicenseInfo(); dns.LicenseInfo.RegisteredUser = new wsStrikeironCom.RegisteredUser(); dns.LicenseInfo.RegisteredUser.UserID = 'withoutme@gmail.com'; dns.LicenseInfo.RegisteredUser.Password = 'vijayv'; // Make the Web service call tempuriOrg.DNSInfo info = dns.DNSLookup('www.google.com'); //tempuriOrg.ArrayOfString arstring=dns.ArrayOfString(); System.debug('Complete INFO:::: '+info); System.debug('HOSTNAMES ARE:::'+ info.AddressList); //System.debug('DNSLookupresult::::'+ DNSLookupResponse_element); // System.debug('arrray of string:::' + tempuriOrg.ArrayOfString); } }

 

vviyervviyer

could you please elaborate on "if that does not work you can construct the SOAP using strings, and send it with HTTP.send() .  This gives your code more control of how the response is parsed."

Any link for info regrding this will be greatly appreciated :). 

dgrigsbydgrigsby

vviyer,

 

I just went down this journey recently.

 

I have done a large post on the subject. Please review and comment on as appropriate.

 

 
or
 

 

1. WSDL - I would highly suggest using a WSDL/XML tool like Atlova XMLSpy (free trial) to examine the Types that are imported. It will allow you to trim down, and integrate the imported (manually - wish they had a merge - going to post that feature request at Atlova) xsd types, etc. I normally work with Visual Studio or Eclipse and they just couldn't get there. It will show you what is in the namespace and what is imported in the WDSL tab visually by color coding.

 

      a. WSDL Apex Class creation Limitations

          -Size of final Apex Class - 100K characters
        -Size of WSDL input - 1Meg
          - No Imports and no implied types from defined named spaces if they contain definitions (xsd which ws-security does).
           -No Attributes (xsd which ws-security does).
           -No annotations (xsd which ws-security does).

           -No multipe bindings (which most do 1 and 12)

 

2. Be prepared to spend some time (read as parse, fix error, rise and repeat) many times

3. Best SF reference I found was Link:

4. In the end, you may find to get it working that the HTTP request and manual soap xml codeup to be the quickest solution to get it running, Twitter and Facebook integrations work this way. It was really faster in the end for me.

5. I cover both in the blog post.

 

Best Regards,

 

 

David W. Grigsby
Grigsby Consulting LLC
Intellectual Capital for Your Business
484 East Carmel Drive Suite 390
Carmel, IN 46032
 
 
Message Edited by dgrigsby on 04-28-2009 03:46 PM
falfadlifalfadli

Compliments on your post dgrigsby. I had a related question I put in another post but I will post it here as well since it is similar.

 

I am working on developing an integration with PayPal. They have a web service API and I wanted to utilize some paypal SOAP libraries. Can I import libraries similar as you would in java?

 

I am trying to avoid building a SOAP message manually and the wsdl2apex class generator does not support the wsdl because of multiple port bindings and imports within the wsdl. And I do not want to hack the wsdl.  

 

Any advice on how to do this would be appreciated so I can set values on the objects and send the request via object method calls....If I cannot, backup plan is to use the HTTP Request and Response classesas you did.

 

 

import com.paypal.sdk.profiles.APIProfile;
import com.paypal.sdk.profiles.ProfileFactory;
import com.paypal.sdk.services.CallerServices;
import com.paypal.soap.api.AddressType;
import com.paypal.soap.api.BasicAmountType;
import com.paypal.soap.api.CountryCodeType;
import com.paypal.soap.api.CreditCardDetailsType;
import com.paypal.soap.api.CreditCardTypeType;
import com.paypal.soap.api.CurrencyCodeType;
import com.paypal.soap.api.DoDirectPaymentRequestDetailsType;
import com.paypal.soap.api.DoDirectPaymentRequestType;
import com.paypal.soap.api.DoDirectPaymentResponseType;
import com.paypal.soap.api.PayerInfoType;
import com.paypal.soap.api.PaymentActionCodeType;
import com.paypal.soap.api.PaymentDetailsType;
import com.paypal.soap.api.PersonNameType;
//Ideally I would like to do something like this.                                                                                                                                              PayerInfoType payer                   PayerInfoType() payer= new PayerInfoType();
PersonNameType name = new PersonNameType();
name.setFirstName(buyerFirstName);
name.setLastName(buyerLastName);
payer.setPayerName(name);
payer.setPayerCountry(CountryCodeType.US);
payer.setAddress(shipTo);