We successfully created Web Service record in previous post and in this post we will do the following:
- Create a button on Contact Form Applet with caption as “Lookup” and method name as “LookupCountry”.
- Create two new fields “IP Address” and “IP Country” on Contact BC
- Expose these two fields on Contact Form Applet
- When we click on Lookup button and there is a valid IP Address in “IP Address” Field it will invoke the GeoIPService’s GetGeoIP method and fetch the country related to that IP and store it in “IP Country” Field.
I am not going to provide configuration steps for creating button and two fields. I assume that you have already created them. Now we will jump on to the invocation part of Web Service.
Create Named Method N (N is a unique number) user property with following value:
“LookupCountry”, “INVOKESVC”, “Contact”, “GeoLookup”, “InvokeWebService”, “‘IPAddress’”, “[IP Address]”
This user property will result in calling of “GeoLookup” Business Service with “InvokeWebService” method when we click Lookup button and it will also pass value of IP Address Field value as an input argument to the business service.
Now the next step and the only step is to write the GeoLookup business service with “InvokeWebService” method which will invoke the web service, receive response and store it in database.
I wrote two variations of GeoLookup business. One uses normal eScript functions to Set and Get properties from Property Set while in other I have used PRM ANI Utility Service “SetProperty” and “GetProperty” methods (just wanted to share usage of these methods)
Before you jump and have a look at the code I must warn you that it is not the most aesthetic piece of code that you are going to see, I have not done any error handling or nullified any objects. In other words it is the bare minimum working code that:
- Creates an empty Property Set
- Sets the Required Properties
- Invokes Web Service and receive response
- Stores the response in database
You can download the code by clicking on the below given links
Code without PRM ANI Utility Service method usage
Code with PRM ANI Utility Service method usage
Now, after going through the code many of you might be wondering that are many other ways (better than this) to acomplish this. I agree with you and I am not finished with the tutorial yet
.
I will be discussing the problems I faced and the alternate approach I tried (rather I would say, trying …) and most importantly how did I debug the problems I faced.
Stay tuned….
<< Previous in series Next in series >>

(5 votes, average: 4.20 out of 5)