Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Object reference not set to an instance of an object.

Posted on 2012-03-29
19
Medium Priority
?
370 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
A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

 
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 1500 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

704 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