InfoCountry

Web Services


  
Web services - Developers code.

 

Below is the code required to access and used the web service. You can skip any section that is already familiar to you. It is however recommended to read section B-D in order to use the service efficiently.
A) Link a client application to the InfoCountry web service (Using VB)
B) Method exposed by the web service and the return properties.
C) How to use the web reference within your code.
D) The Complete example of the web service code (Using VB).
E) Unregistered web service tests.
  
A) Link a client application to the InfoCountry web service (Using VB). 
    To use the web service method inside your Visual Studio application you must make a reference to it within your application.
 

 A) Go to: Project/Add Web Reference...
      

From the pop-up:

B) At the URL add our web reference:
http://www.infocountry.co.za /za/default/webservice/ SMSService.asmx

C) For the Web reference name:
Use the name for which you would like to refer to the web service (In the example we use: IC_WebService).

D) Press the ''Add Reference" button to add the web service to your application.

Now, use the Web reference name (Ex: IC_WebService in the above example ) within your application to refer to the web service method.

 
B) Method exposed by the web service and the return properties. 

For the InfoCountry SMS Service there is only one method available: SMSInfo. This method is used to send a SMS request to the InfoCountry web service. The method also require parameters in order to process your request, these parameters is as follows:

Parameter Description Message from: Data Type
UserName  The secret name to allow you access to the service. Provided by JBNet. String
Password  The secret password to allow you access to the service. Provided by JBNet. String

* RequestType  The type of request you made (Use: SMS or WebService) Type in 'SMS' or 'WebService' String
RequestMsg  The information which you requested. Type in one of the available SMS service commands. String
RequestRef  Specify from where the message is coming from. If the RequestType is 'SMS' the enter your cell phone number in, Else If the RequestType is 'webservice' then enter your web site URL in. String
* RequestType 
If you choose 'SMS' then the message length will be 130 characters maximum. If you choose 'WebService' then the full length of the message will be returned (For requests summeries like: news, specials, catalog... the return value might be very long, when using RequestType  = 'WebService')

The method is used like this: SMSInfo(UserName As String, Password As String, RequestType As String, RequestMsg As String, RequestRef as String)

The method exposed four return (result) properties: These are:

Parameter Description Data Type
ResponseMsg  The response from the RequestMsg which was sent. String
ResponseDesc  Describe the task which was performed by the request. String
ErrMsg  The error message, if an error has occurred. String
IsValid  Indicate if an error has occurred during the request. Boolean
  
C) How to use the web reference method within your code. 

Within your code make two new instances:

The first instance is used to send information to the service:
Dim IC As New IC_WebService.InfoCountry               ' Note: The method to use is: SMSInfo

The second is to read from the service.
Dim ICprop As New IC_WebService.SMSInfoProperties

Now set the response values to the method within the class which is called:
ICprop = IC.SMSInfo( UserName As String, Password As String, RequestType As String, RequestMsg As String, RequestRef as String)

Finally, use the class response properties to view the result:

First! Check if the message has processed successfully, then display the response messages:

  If Not ICprop.IsValid Then
    MessageBox.Show(ICprop.ErrMsg)
           ' Error in message.
  Else

    lblResMsg.Text = ICprop.ResponseMsg
    lblResDesc.Text = ICprop.ResponseDesc

  End If

If the message was not processed successfully then try to make a new request to the service. The way you use the response properties is up to you. For those who do not use VB, the principle to access the web service and to use it in code is not much different.

  
D) The complete example of the web service code (Using VB). 
 
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

  Dim IC As New IC_WebService.InfoCountry
  Dim ICprop As New IC_WebService.SMSInfoProperties

  ICprop = IC.SMSInfo(txtUser.Text, txtPass.Text, cboType.Text, txtMessage.Text, txtPhone.Text)

  If Not ICprop.IsValid Then
    MessageBox.Show(ICprop.ErrMsg)              ' Error in message.
  End If

  lblResMsg.Text = ICprop.ResponseMsg
  lblResDesc.Text = ICprop.ResponseDesc
  lblResErr.Text = ICprop.ErrMsg
  lblResValid.Text = ICprop.IsValid

End Sub
  
E) Unregistered web service tests. 
As mentioned in section B you required a username and password in order to access the web service method. For test purposes and for you to verify your code we have implement a default username and password that you can use to test the service. The request return message will be the same for all your requests you made (if the request is valid), and this will allows you to see if your code and web references was set-up correctly.
  
For test purposes use:
Username: "test"
Password: "test"
   
If your request was successful you will receive the following message: Congratulations! You have successfully access our web service. Please contact JBNet to provide you with a Username and Password.
  

 
Related links:
- Web service page: http://www.infocountry.co.za/za/default/webservice/SMSService.asmx
- The complete list of messages that can be sent by the web service: SMS Service
- For support and contact detail view the JBNetInfo page: JBNet - about us
  

All the messages is based on the JBNumber reference and different business information can be access by replacing one JBNumber with another business JBNumber.

The web service use South Africa as the selected country.
The 'za' reference used within the messages refers to the international two characters standard for South Africa.
Only information from South Africa is available on InfoCountry databases, but the service is internationally available.

[InfoCountry web services] [Developers code] [Sample code] [Registration detail] [Policies]

   

Page: 2 / 5

  

For any information related to this document, please call or E-Mail JBNet directly. A better solution is to directly get in contact with your local Supervisor. The details of the Supervisor contact number is available on the InfoCountry web site.
   

E-Mail: Info@JBNet.co.za

Internet: http://www.infocountry.co.za

Ref. No: jbl050_0910