Very simple requirements here:
- connect to web service
- check if account number exists
- if it exists update it
- if it does not exist create the account
I have accomplished this with the code below I am wondering if this is efficient and secondly if there is a better way of doing this.
protected void Button1_Click(object sender, EventArgs e)
{
//authentication header
com.x.w_1.www.WebService ws = new com.x.w_1.www.WebService();
com.dat_e_baseonline.w_1.www.AuthenticationHeader header = new com.x.w_1.www.AuthenticationHeader();
header.UserName = "";
header.Password = "";
ws.AuthenticationHeaderValue = header;
string email = TextBox1.Text.ToString();
//Are they a subscriber?
XmlNode result = ws.getAccountIDbyEmail(email, "247");
Label1.Text = result.OuterXml;
foreach (XmlNode x in result.FirstChild)
{
string m = x.InnerText;
string account = result.LastChild.InnerText;
switch (m)
{
case "100":
//update the account
ws.Subscribe("x", "3", account);
Label1.Text = "account exists";
break;
case "200":
//create an account
ws.createAccount("x", "5", email, "x", "x", "x", "01-01-1998", "1", "yes");
Response.Redirect("/thankyou.aspx");
break;
}
}
For reference here is the XML I get back when I send an email to be updated:
<getAccountID:name xmlns:getAccountID="http://x">
<getAccountIDResultCode xmlns="">100</getAccountIDbyEmailResultCode>
<getAccountIDResultDescr xmlns="">Account found.</getAccountIDResultDescr>
<accountID xmlns="">12345</accountID>
</getAccountIDbyEmail:name>