Re: PLEASE HELP - object reference not set to instance of an object
From: Dan Rogers (danro_at_microsoft.com)
Date: 11/30/04
- Next message: Dan Rogers: "RE: Calling webservices from a Pocket PC"
- Previous message: Dan Rogers: "RE: ASP.Net not impersonating for WSE 2.0"
- Maybe in reply to: Keith Chadwick: "PLEASE HELP - object reference not set to instance of an object"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 30 Nov 2004 00:52:55 GMT
Hi Keith,
Remember, that everything outside of the Body element in the soap envelope
will not be passed to the method (this is why you get an XMLNode and not an
XML document). You shouldn't have to do a loadXMl at all, since the
serialization to an XmlNode is already finished at this point.
Here are some questions:
1. Is the XmlNode member named Data non-null when the method is invoked?
2. If it is non-null, it is an XMlNode and you can use it as an object
reference. The next question is what line of code is throwing the
uninitialized object exception? I suspect it is when you try to use the
node reference that can be returned by selectSingleNode. Remember, if
SelectSingleNode doesn't find anything, it returns null.
Adding namespaces won't do much for you since this isn't a namespace issue.
From the data you see coming back from your <ROOT> experiment, it seems
that the original request data is making it into your method just fine.
The non-namespace on your concatenated root node is what is making all of
those added child namespace markup appear - so again, the serializer seems
to be doing it's job correctly.
What is left to conclude then is that the Xpath expression is saying that
no results are found. You need to accommodate namespace in your xpath
queries - so I suspect your test is looking for Test in the non-namespace,
when your data is namespaced.
I hope this helps
Dan Rogers
Microsoft Corporation
--------------------
>From: "Keith Chadwick" <webmaster-nospam@allianceevents.com>
>References: <#qG4gTl1EHA.3500@TK2MSFTNGP09.phx.gbl>
<bfe1rkl1EHA.3388@cpmsftngxa10.phx.gbl>
>Subject: Re: PLEASE HELP - object reference not set to instance of an
object
>Date: Mon, 29 Nov 2004 16:31:04 -0500
>Lines: 70
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
>X-RFC2646: Format=Flowed; Original
>Message-ID: <e$LqSul1EHA.1740@TK2MSFTNGP15.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
>NNTP-Posting-Host: ottawa-hs-64-26-156-220.s-ip.magma.ca 64.26.156.220
>Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXS01.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP15.phx.gbl
>Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:26878
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
>
>Been trying everything Dan with no luck.
>
>Have done the following:
>
>Public Function submitContact(ByVal data As XmlNode) As xmldocument
> Dim result As String
> Dim resultDoc as new XmlDocument
>
> resultDoc.loadxml("<root>" & data.innerXML() & "</root>")
>
> return resultDoc
>End
>
>The xml comes back fine the same way I sent it down!!!
>
>But if I do anything like
>myElement=resultDoc.selectSingleNode("ROOT/contact/Title") it allways
>allways no matter what comes back with the same error that I did not
create
>a new instance when I try to get at the element.
>
>I tried a test=resultDoc.selectNodes("ROOT/contact/Title").count and it
>always comes back as 0 for count. I am missing something obvious here.
>
>In my example above the XML document that is returned to is below:
>
><?xml version="1.0" encoding="utf-8"?><soap:Envelope
>xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><submitContactRespo
nse
>xmlns="evententerprise"><submitContactResult><ROOT xmlns=""><Title
>xmlns="evententerprise">Mr</Title><GivenName
>xmlns="evententerprise">Andi</GivenName><MiddleName
>xmlns="evententerprise">Thornton</MiddleName><Surname
>xmlns="evententerprise">Cooper</Surname><Department
>xmlns="evententerprise">department</Department><Assistant
>xmlns="evententerprise">Assistants%20Name</Assistant><Manager
>xmlns="evententerprise">Managers%20Name</Manager><Profession
>xmlns="evententerprise">profession</Profession><JobTitle
>xmlns="evententerprise">Job%20Title</JobTitle><EmployeeNumber
>xmlns="evententerprise">employee%20number</EmployeeNumber><Company
>xmlns="evententerprise">Company</Company><Language
>xmlns="evententerprise">English</Language><email1
>xmlns="evententerprise">andic@magma.ca</email1><email2
>xmlns="evententerprise">email2@hotmail.com</email2><email3
>xmlns="evententerprise">email3@hotmail.com</email3><email
>xmlns="evententerprise">email1</email><webpage
>xmlns="evententerprise">http://web%20page%20address><BusinessPhone
>xmlns="evententerprise">business%20phone</BusinessPhone><HomePhone
>xmlns="evententerprise">home%20phone</HomePhone><BusinessFax
>xmlns="evententerprise">bus%20fax</BusinessFax><Mobile
>xmlns="evententerprise">mobile</Mobile><Street
>xmlns="evententerprise">street%20name</Street><City
>xmlns="evententerprise">city</City><State
>xmlns="evententerprise">state</State><PostalCode
>xmlns="evententerprise">postal</PostalCode><Country
>xmlns="evententerprise">country</Country></ROOT></submitContactResult></sub
mitContactResponse></soap:Body></soap:Envelope>
>
>If have also tried doing the following :
>
>nsmgr.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
>nsmgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/")
>
>nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
>
>nsmgr.AddNamespace("", "evententerprise")
>
>
>I am missing something but just can't figure it the hell out!!!
>
>
>
- Next message: Dan Rogers: "RE: Calling webservices from a Pocket PC"
- Previous message: Dan Rogers: "RE: ASP.Net not impersonating for WSE 2.0"
- Maybe in reply to: Keith Chadwick: "PLEASE HELP - object reference not set to instance of an object"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|