Solved

Object reference not set to an instance of an object.

Posted on 2012-03-29
19
348 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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

930 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

16 Experts available now in Live!

Get 1:1 Help Now