Question How to Consume Web Services?

AdeptDeveloper

New member
Joined
Aug 4, 2008
Messages
2
Programming Experience
10+
Hi,

I'm relatively new to VB.Net. I used variations of VB years ago, but I might as well be a newbie at it now. I have a WSDL written in ColdFusion that has a method called TrackTest and accepts one argument (string) and returns an integer representing the length of the string.

My VB Code looks like:

VB.NET:
    Dim objACService As ServiceReference1.CollectorService_v1 = New ServiceReference1.CollectorService_v1Client
    Dim trackRequest As ServiceReference1.TrackTestRequest = New ServiceReference1.TrackTestRequest
    Dim objContact As Outlook.ContactItem
    objContact = TryCast(Me.OutlookItem, Outlook.ContactItem)

    Dim strFullName As String = objContact.FullName
    trackRequest.Body.str = strFullName

The last line is the error. When I assign the trackRequest.Body.str (str is the argument name for the TrackTestRequest) to strFullName and run it, I get a NullPointerReference error, however, if I take the trackRequest.Body.str part out and replace it with Label1.Text then the strFullName value is assigned to the label and it works correctly, I just don't understand why I get a NullPointerReference when I try to assign it to the trackRequest.Body.str variable.

Thanks,
-Steve
 
Would guess Body property is a class type, and you haven't created a object instance for this and assigned to Body yet.
 
Yes, that's what it was.

The Body type had to be declared and once I discovered that and started using more structured WSDL methods, you have to declare each new XML Node as an object and then assign the values to it.

Thanks,
-Steve
 
Back
Top