Solved

Object reference not set to an instance of an object.

Posted on 2012-03-29
19
347 Views
Last Modified: 2012-06-28
I am using a .wsdl file in VB.Net to send some quotation data to a 3rd party.

I have added the service reference and am attempting to call the action method but I get the error 'Object reference not set to an instance of an object'. The error is on the last line of the code...

Can anybody help?

 Dim ws As ExchangeServicesType

        Dim actionReq As New actionExchangeServicesRequest
        Dim actionResp As New actionExchangeServicesResponse

        Dim reqHeader As New Header2
        reqHeader.service_id = "GetAnnuityQuoteV1"

        Dim reqMessage As New Message

        Dim reqMsgHeader As New Header
        reqMsgHeader.business_contract_id = "...."
        reqMsgHeader.message_timestamp = Now
        reqMsgHeader.message_id = System.Guid.NewGuid.ToString
        reqMsgHeader.service_id = "GetAnnuityQuoteV1"
        reqMsgHeader.integrator_id = "..........."
        reqMsgHeader.orchestration_id = System.Guid.NewGuid.ToString
        reqMsgHeader.business_contract_id = "......"
        reqMsgHeader.Item = New Object
        reqMsgHeader.payload_provider = "................"
        reqMsgHeader.service_provider_id = ".........."
        reqMsgHeader.transaction_id = "0"

        Dim reqMsgPayload As New Payload
        reqMsgPayload.message = New OrigoMessage

        reqMessage.header = reqMsgHeader
        reqMessage.payload = reqMsgPayload

        actionReq.exchange_services = reqHeader
        actionReq.exchange_services1 = reqMessage

        actionResp = ws.actionExchangeServices(actionReq)
0
Comment
Question by:ict-torquilclark
  • 10
  • 9
19 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
Add "New" to the first line.

i.e.

Dim ws As New ExchangeServicesType

Open in new window

0
 
LVL 1

Author Comment

by:ict-torquilclark
Comment Utility
I thought of that it underlines "ExchangeServicesType" and errors with 'New cannot be used on an interface'
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
There should have been a class generated whose name ends in the string "Client". If you create an instance of that, you should be good.

e.g.

Dim ws As New ExchangeServicesClient

...

actionResp = ws.actionExchangeServices(actionReq)

Open in new window

0
 
LVL 1

Author Comment

by:ict-torquilclark
Comment Utility
Is there any chance you can give me a quick example?
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
Is the WSDL sensitive? Can you post it?
0
 
LVL 1

Author Comment

by:ict-torquilclark
Comment Utility
I don't see why not. Have had to attach as a text file as it wouldn't let me as a .wsdl
GetAnnuityQuoteV1.txt
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
I was going to try and add the reference in a sample project and then tell you the specific class name, but your WSDL depends on a few other XSD files, so that's not going to work. I am not very adept at reading WSDL files an interpreting what they would be in code, so I'll have to take different approach with you:  Can you look through the list of generated classes for that WSDL file and tell me if there is any class whose name ends in "Client"?
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
The other alternative would be to post the following files:

ESGetAnnuityQuoteRequestV1.xsd
ESGetAnnuityQuoteRequestV1.xsd
ESGetAnnuityQuoteRequestV1.xsd

If you are comfortable posting those, then I can resume my previous attempt. If you'd rather look through your class list for the "Client" reference, then I am fine with that as well.
0
 
LVL 1

Author Comment

by:ict-torquilclark
Comment Utility
Ok I have found the class 'personal_client'.

What do I do to use it now?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
I don't think that is the class. I've never seen the wizard create a class where the name had an underscore in it (I suppose it could be possible, though).

How about this:  If you "Show All Files" in Solution Explorer, then you expand out the service reference, do you have a "Reference.cs" file available?

Solution Explorere - Reference.cs
If so, double-click that file to open it up in the editor. Once that is done, what classes do you see in the left-side drop-down just above the code editor pane?

Drop-down Class Listing
I have highlighted the "Client" class in the screenshot above. You would be looking for something similar to that. That class is the one you would create an instance of.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
P.S.

The above are screenshots of a project I am working on (not the one we are discussing). Those names are specific to my project, and I am using them for demonstration only. They will not be the names you see in your project. Your primary focus is finding the class which contains "Client" in its name.
0
 
LVL 1

Author Comment

by:ict-torquilclark
Comment Utility
I ahve done that and there are quite a few classes.

Here is a screenshot.
Untitled.jpg
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
OK, my mistake. It seems that is indeed how they are named. All that should be required then is that you create an instance of the class, and then call the appropriate method:

Dim ws As New personal_client()

...

actionResp = ws.actionExchangeServices(actionReq)

Open in new window

0
 
LVL 1

Author Comment

by:ict-torquilclark
Comment Utility
ActionExchangeServices isn't a method of personal_client

I can make the XSD files available if that would help?
0
 
LVL 1

Author Comment

by:ict-torquilclark
Comment Utility
here they are...
New-folder.zip
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
As I suspected, you are looking at the wrong class within that document--which is OK. If you go further down the class list, you will see a class named ExchangeServicesTypeClient. This is the class you are after.

Dim ws As New ExchangeServicesTypeClient()

...

actionResp = ws.actionExchangeServices(actionReq)

Open in new window

0
 
LVL 1

Author Comment

by:ict-torquilclark
Comment Utility
ExchangeServicesTypeClient requires two things to be passed to it
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
The method actionExchangeServices does.
0
 
LVL 1

Author Comment

by:ict-torquilclark
Comment Utility
can you see what two things i need to pass to it?
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now