Help accessing a web service

critical5

Member
Joined
Jan 10, 2007
Messages
8
Programming Experience
1-3
Hi I am trying to access a third party web service...I have added a web reference to my project and I am trying to access it. This web service does a credit search...I am a beginner in VB.NET as well so problems occur often:


At the moment I am getting the following error:
variable 'inp' has been used before it has been defined. A null reference could result at run time
on this code:

HTML:
1 <%@ Page Language="VB"%>
2 
3 <script runat="server">
 
12 
13 Dim cc As CallcreditAPI.CallcreditAPI = New CallcreditAPI.CallcreditAPI
14 cc.Url = "myurl"
15 cc.credentials = New CallcreditAPI.CT_credentials
16 cc.credentials.company = "company"
17 cc.credentials.username = "username"
18 cc.credentials.password = "pwd"
19 cc.action = New CallcreditAPI.ST_action
20 cc.action.Text = New String(1) {}
21 cc.action.Text(0) = "urn:callcredit.plc.uk/api/actions/5305"
22 Dim inp As CallcreditAPI.CT_apicr
23 inp.creditrequest = New CallcreditAPI.CT_apicreditrequest
24 inp.creditrequest.score = 1
25 inp.creditrequest.scoreSpecified = True
26 inp.creditrequest.purpose = CallcreditAPI.ST_searchpurpose.CA
27 inp.creditrequest.applicant = New CallcreditAPI.CT_apirequestapplicant() {}
28 inp.creditrequest.applicant(0) = New CallcreditAPI.CT_apirequestapplicant
29 inp.creditrequest.applicant(0).address = New CallcreditAPI.CT_inputaddress() {}
30 inp.creditrequest.applicant(0).address(0) = New CallcreditAPI.CT_inputaddress
31 inp.creditrequest.applicant(0).address(0).premiseno = Me.txtPremiseNum.Text
32 inp.creditrequest.applicant(0).address(0).postcode = Me.txtPostcode.Text
33 inp.creditrequest.applicant(0).name(0) = New CallcreditAPI.CT_name
34 inp.creditrequest.applicant(0).name(0).forename = Me.txtForename.Text
35 inp.creditrequest.applicant(0).name(0).surname = Me.txtSurname.Text
36 inp.creditrequest.applicant(0).name(0).title = Me.txtTitle.Text
37 inp.creditrequest.applicant(0).dob = System.DateTime.Parse(Me.txtDoB.Text)
38 inp.creditrequest.applicant(0).dobSpecified = True
39 cc.Job5305(inp)
40 If 0 = inp.picklist.applicant(0).address(0).fullmatches.fullmatch(0).selected Then
41 inp.picklist.applicant(0).address(0).fullmatches.fullmatch(0).selected = 1
42 cc.credentials.password = ""
43 cc.Job5305(inp)
44 End If
45 If 0 = inp.picklist.applicant(0).address(0).fullmatches.fullmatch(0).name(0).namematches.namematch(0).selected Then
46 inp.picklist.applicant(0).address(0).fullmatches.fullmatch(0).name(0).namematches.namematch(0).selected = 1
47 cc.credentials.password = ""
48 cc.Job5305(inp)
49 End If
50 End Sub
51 </script>
52 
53 <html xmlns="http://www.w3.org/1999/xhtml" >
54 <head>
55 <title>CallCreditAPI</title>
56 </head>
57 <body>
58 <form id="Form1" runat="server">
59 <table>
60 <tr>
61 <td>
62 Title: </td>
63 <td>
64 <asp:textbox id="txtTitle" runat="server"></asp:textbox>
65 </td>
66 </tr>
67 <tr>
68 <td>
69 Forename:</td>
70 <td>
71 <asp:textbox id="txtForename" runat="server"></asp:textbox>
72 </td>
73 </tr>
74 <tr>
75 <td>
76 Surname:</td>
77 <td>
78 <asp:textbox id="txtSurname" runat="server"></asp:textbox>
79 </td>
80 </tr>
81 <tr>
82 <td>
83 Date Of Birth:</td>
84 <td>
85 <asp:textbox id="txtDoB" runat="server"></asp:textbox>
86 </td>
87 </tr>
88 <tr>
89 <td>
90 Premise:</td>
91 <td>
92 <asp:textbox id="txtPremiseNum" runat="server"></asp:textbox>
93 </td>
94 </tr>
95 <tr>
96 <td>
97 Postcode:</td>
98 <td>
99 <asp:textbox id="txtPostcode" runat="server"></asp:textbox>
100 </td>
101 </tr>
102 <tr>
103 <td>
104 Score:</td>
105 <td>
106 <asp:textbox id="txtScore" runat="server"></asp:textbox>
107 </td>
108 </tr>
109 <tr>
110 <td>
111 Searches:</td>
112 <td>
113 <asp:textbox id="txtSearches" runat="server"></asp:textbox>
114 </td>
115 </tr>
116 <tr>
117 <td>
118 <asp:button id="score" runat="server" text="Score" OnClick="score_Click" />
119 </td>
120 </tr>
121 </table>
122 </form>
123 </body>
124 </html>
 
Last edited by a moderator:
At line 22, you declare the variable but don't assign a value to it.
I'm not familiar with the CallcreditAPI.CT_apicr object so I can't be sure but you may want to change line 22 to:
VB.NET:
        Dim inp As New CallcreditAPI.CT_apicr
 
End Of statement Expected

Hi I have amended the code as above and this seems to be working but I still get an " End of statement Expected" on line 23

Dim inp As New CallcreditAPI.CT_apicr()
Dim inp.creditrequest = New CallcreditAPI.CT_apicreditrequest
inp.creditrequest.score = 1

Can you help??
Critical5
 
This is now sorted out but I get a Warning pup up:
Index was outside the bounds of the array
on this line:

inp.creditrequest.applicant(0) = New CallcreditAPI.CT_apirequestapplicant()
I do not know much about arrays... any help out there would be appreciated!!! I really need to get this done...one of my new year's resolution:D

any help on msn migambi_2@hotmail.com is welcome!
 
The error means that the index you supplied (zero in this case) is not a valid index in the array. Since I have no knowledge of this CallcreditAPI class, I can't say what it should be.
You can always step through the code and use the locals and watch windows as well as hovering over different variables to find out what certain values are during execution. In your case, set a breakpoint in the method and after instantiating the inp variable, hover over the word application in
inp.creditrequest.applicant and you will get a popup that will show all the members and values of that class. Or while stepping through the code high lite inp.creditrequest.applicant, right click it and Add Watch; the same information will appear in the watch window.

Good luck.
 
This is strange...when I add a watch at runtime, i get this description:

name Value
inp.creditrequest.applicant {Length=0}

type
CallcreditAPI.CT_apirequestapplicant()

It shows value of length 0 so why isn'it accepting my statement above...unless this means something else.

Thanks

Critical5
 
An array with a length of zero is an empty array.
Arrays in .NET 2 are by default zero-based (you can change this but it's not a good idea) so index zero would be the first item in the array. Attempting to reference the first item in an empty array will result in the "Index was outside the bounds of the array" error.
 
Hi, I have managed to connect to a this web service...but I do not know how to handle the returned data....for example what controls I need to hold my data....which would be under the form of array....considering this would be a an applicant credit history...I would welcome any ideas on how to interface this web service....thanks

Critical5
 
Back
Top