THURSDAY, AUGUST 07, 2008




MY ACCOUNT LOGIN

LOGIN NAME:

PASSWORD:

REGISTER TODAY!
FORGOT YOUR PASSWORD?
TRY ALL WEB SERVICES
FREE FOR 30 DAYS!

WEB SERVICES

XWEBEMAILVALIDATION [tool]

XWEB1003 [real estate]

XWEBACHDIRECTORY [financial]

XWEBCHECKOUT [ecommerce]

XWEBTD [ecommerce]

XWEBNEWS [content mgmt.]


ANNOUNCEMENTS


NEW IMPLEMENTATION GUIDE AVAILABLE: "XWEBLEAD CLIENT 2.0”

XWEBLEAD VERSION 2 LAUNCHED

XWEBLEAD WEB SERVICE NOW FEATURES SSL SECURITY



Web Services, SOA Solutions, SOA Services - XWebServices.com


HOME

WEB SERVICES

SOA SOLUTIONS

SOA SERVICES

ABOUT US





XWEBLEAD


Documentation


FAQs


Implementation Guides


Forum


Pricing






SEARCH









HOME  ::  WEB SERVICES  ::  XWEBLEAD  ::  IMPLEMENTATION GUIDES

:: Web Services :: XWebLead :: Implementation Guides ::

Creating an XML/SOAP Web Service Based Lead Management System:
How-To Display A Specific Lead

The procedures in this implementation guide require that you have some knowledge of XML and ASP.NET web development with the Microsoft Visual Basic.NET development tool.

The steps in this "how-to" implementation guide are:

To download the source code for this "how-to" implementation guide, as well as for additional hints and tips, please read our Final Notes.

Add a "Web Reference" to the XWebLead Web Service

  • In your web project, add a Web Reference to the XWebLead web service. Here are 2 ways you can accomplish this:

    • Browse the Solution Explorer, right click on References and select Add Web Reference... from the drop down menu.
    • From the File Menu, select Project - Add Web Reference....
  • The Add Web Reference pop-up window will open. In the URL textbox, enter the following URI:

    http://ws.xwebservices.com/XWebLead/XWebLead.asmx?wsdl

  • Hit the Enter key or click the Go button located to the right of the URL textbox.
  • Change the Web reference name to XWebLead for easier reference.
  • Click the Add Reference button to complete this step.

Add a "Web Form" to the Web Application

  • In your web project, add a Web Form. This Web Form will display the details of the Lead you select from the queue. Here are 2 ways you can accomplish this:

    • Browse the Solution Explorer, right click the name of your project, and select Add - Add Web Form....
    • From the File Menu, select Project - Add Web Form....
  • Change the Name textbox in the Add New Item pop-up provided to lead.aspx.

Write code in the "Codebehind" of the web form to retrieve the Lead record by consuming the XWebLead Web Service

Based on the documentation for the XWebLead Web Service, in order to successfully consume the Web Service, we will need to authenticate first using SOAP Headers. Here's how:

  • Open the "Codebehind" of the lead.aspx web form we added to the web project in the previous step.
  • Since the Web Service requires SOAP Headers for authentication purposes, we must first create a new instance of the class representing the SOAP Header and then populate the SOAP Header values:

    ' handle authentication
    Dim objAuth As New XWebLead.AuthHeader
    objAuth.LoginName = "<my_login_name>"
    objAuth.Password = "<my_password>"

    NOTE***: Instead of hard-coding the LoginName and Password values, you may want to dynamically read them from the web.config file (LOGIN_NAME and PASSWORD must be added to the <AppSettings> section of the web.config file):

    objAuth.LoginName = System.Configuration.ConfigurationSettings.AppSettings("LOGIN_NAME")
    objAuth.Password = System.Configuration.ConfigurationSettings.AppSettings("PASSWORD")

  • Next, we need to create a new instance of the proxy class and assign the SOAP Header object to the member variable of the proxy class representing the SOAP Header:

    'create the XWebLead Web Service proxy
    Dim objLead As New XWebLead.XWebLead
    objLead.AuthHeaderValue = objAuth

  • We are now ready to call the method on the proxy class that communicates with the Web Service method and returns the Lead record we want displayed on the web page.

    'the querystring parameter should be in this format "lid=xxx"
    'store the result in a variable
    Dim strLeadXML As String =
    objLead.LoadLead(Request.QueryString("lid").ToString)

Implement ASP.NET Labels to display the Lead's details

In the Codebehind:

  • Declare the 5 labels which will display the Lead's details (Lead ID, Source Identifier, Description, Body and Created Date):

    Protected lblLeadID, lblSourceID, lblDescription, lblBody, lblDateCreated As System.Web.UI.WebControls.Label

  • Load the XML string we previously stored in the strLeadXML variable into an XMLDocument:

    'load an XML DOM with the <Lead> xml string returned by the Web Service SOAP method
    Dim objDOM As New System.Xml.XmlDocument
    objDOM.LoadXml(strLeadXML)

  • Set the labels' Text property to the corresponding Element or Attribute value:

    lblLeadID.Text =
    objDOM.DocumentElement.Attributes.ItemOf("Lead_ID").Value
    lblSourceID.Text =
    objDOM.DocumentElement.SelectSingleNode("Source_Identifier").InnerText
    lblDescription.Text =
    objDOM.DocumentElement.SelectSingleNode("Description").InnerText
    lblBody.Text =
    objDOM.DocumentElement.SelectSingleNode("Body").InnerText
    lblDateCreated.Text =
    objDOM.DocumentElement.Attributes.ItemOf("Date_Created").Value

In the HTML Editor, we simply define the 5 ASP.NET labels which will display the Lead's details. Here is the code:

<asp:Label ID="lblLeadID" Runat="server" />
<asp:Label ID="lblSourceID" Runat="server" />
<asp:Label ID="lblDateCreated" Runat="server" />
<asp:Label ID="lblDescription" Runat="server" />
<asp:Label ID="lblBody" Runat="server" />

Final Notes

The source code for this "how-to" implementation guide can be downloaded by clicking the link below (zip file, contains the source code for all "how-to" implementation guides for the XWebLead Web Service)

XWebLeadClient.zip

It's always good practice to implement a Try...Catch... error handling technique to handle some or all possible errors that may occur while the code is executing. We strongly recommend that you implement such a technique.



HOME
WEB SERVICES
SOA SOLUTIONS
SOA SERVICES
MY ACCOUNT
ABOUT US