Solved

Object reference not set to an instance of an object.

Posted on 2012-03-29
19
361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Copying from a network share 3 38
Send SMS from vb.net desktop app 30 53
VB .net 2010 Byte array 2 24
ErrorKind in crystal reprot VB.Net 1 19
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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, …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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