Solved

Object reference not set to an instance of an object.

Posted on 2012-03-29
19
350 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 75

Expert Comment

by:käµfm³d 👽
ID: 37781248
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
ID: 37781252
I thought of that it underlines "ExchangeServicesType" and errors with 'New cannot be used on an interface'
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37781297
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 1

Author Comment

by:ict-torquilclark
ID: 37781301
Is there any chance you can give me a quick example?
0
 
LVL 75

Expert Comment

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

Author Comment

by:ict-torquilclark
ID: 37781355
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 75

Expert Comment

by:käµfm³d 👽
ID: 37781411
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 75

Expert Comment

by:käµfm³d 👽
ID: 37781420
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
ID: 37781472
Ok I have found the class 'personal_client'.

What do I do to use it now?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37781676
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 75

Expert Comment

by:käµfm³d 👽
ID: 37781689
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
ID: 37781859
I ahve done that and there are quite a few classes.

Here is a screenshot.
Untitled.jpg
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37781900
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
ID: 37781916
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
ID: 37781925
here they are...
New-folder.zip
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37782111
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
ID: 37782229
ExchangeServicesTypeClient requires two things to be passed to it
0
 
LVL 75

Accepted Solution

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

Author Comment

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

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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