ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 17th, 2003, 03:52 PM
talonx32 talonx32 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 talonx32 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Object variable or With block variable not set (Error 91)

Hi all this is my very first post I am new to Soap so when I try to run this sample code I get a "Object variable or With block variable not set (Error 91)" on the line were the arrow is pointing to the references are all there and I even tried different MSXML v4 ,v3 and v2.6 versions can some one help me out. I really what to work thanks.

Private XMLDoc As New MSXML2.DOMDocument
Private mstrNameSpace As String

Public Sub AddMethod(ByVal Class As String, ByVal Method As String)
'This procedure adds a method to the soap envelope
Dim NS As String

'If namespace set, use it.
If mstrNameSpace = "" Then
NS = Class
Else
NS = mstrNameSpace
End If

With XMLDoc
problem --->> .selectSingleNode("SOAP:Envelope/SOAP:Body").appendChild .createNode(NODE_ELEMENT, Class & ":" & Method, NS)
End With

Exit Sub

Handle_Error:
Err.Raise Err.Number, "AddMethod: " & Err.Source, _
Err.Description
End Sub

Reply With Quote
  #2  
Old October 17th, 2003, 05:29 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 16
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
If you bring the object into the sub, it believe this could work

Public Sub AddMethod(ByVal Class As String, ByVal Method As String, ByVal XMLDOC as MSXML2.DOMDocument)
__________________
- Rogier Doekes

Reply With Quote
  #3  
Old October 20th, 2003, 09:00 AM
talonx32 talonx32 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 talonx32 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your reply Rogier Doekes but it did not work
I can not pass the xmldoc object because I Instantiate the object in Class_Initialize I'm going to post the whole class and maybe you or somebody can
help thanks in advance


Private XMLDOC As MSXML2.DOMDocument
Private mstrNameSpace As String

Public Sub AddMethod(ByVal Class As String, ByVal Method As String)
'This procedure adds a method to the soap envelope
Dim NS As String

'If namespace set, use it.
If mstrNameSpace = "" Then
NS = Class
Else
NS = mstrNameSpace
End If

With XMLDOC
.selectSingleNode("SOAP:Envelope/SOAP:Body").appendChild .createNode(NODE_ELEMENT, Class & ":" & Method, NS)
End With

Exit Sub

Handle_Error:
Err.Raise Err.Number, "AddMethod: " & Err.Source, _
Err.Description
End Sub

Public Sub AddParameter(ByVal Class As String, _
ByVal Method As String, ByVal ParamName As String, _
ByVal ParamValue As String)
'This procedure adds a parameter to the indicated method

Dim xmlElement As MSXML2.IXMLDOMElement
Dim xmlNode As MSXML2.IXMLDOMNode

Set xmlElement = XMLDOC.createElement(ParamName)

xmlElement.Text = ParamValue

Set xmlNode = XMLDOC.selectSingleNode("SOAP:Envelope" & _
"/SOAP:Body/" & Class & ":" & Method)

If Not xmlNode Is Nothing Then
xmlNode.appendChild xmlElement
End If
Exit Sub

Handle_Error:
Err.Raise Err.Number, "AddParameter: " & _
Err.Source, Err.Description
End Sub

Public Sub AddResponse(ByVal Class As String, _
ByVal Method As String, ByVal Response As String)
'This procedure adds a response to the envelope
Dim xmlResponse As New MSXML2.DOMDocument
Dim xmlNode As MSXML2.IXMLDOMNode
Dim NS As String

'If namespace set, use it.
If mstrNameSpace = "" Then
NS = Class
Else
NS = mstrNameSpace
End If

xmlResponse.loadXML Response

With XMLDOC
Set xmlNode = .createNode(NODE_ELEMENT, Class & _
":" & Method, NS)
problem-->.selectSingleNode("SOAP:Envelope/SOAP:Body") _
.appendChild xmlNode
End With

With xmlNode
.appendChild XMLDOC.createElement("Response")
.selectSingleNode("Response").appendChild _
xmlResponse.documentElement
End With
Set xmlResponse = Nothing
Set xmlNode = Nothing

Exit Sub

Handle_Error:
Err.Raise Err.Number, "AddResponse: " & _
Err.Source, Err.Description
End Sub

Public Property Get xml() As String
'This property returns the soap envelope
xml = XMLDOC.xml

End Property

Private Sub Class_Initialize()
Dim CONTOP As String

CONTOP = "<SOAP:Envelope xmlns:SOAP=" & Chr(34) & "HTTP" & Chr(58) & "//schemas.xmlsoap.org/soap/envelope/" & Chr(34) & ">"

Set XMLDOC = New MSXML2.DOMDocument

With XMLDOC
.async = False
.loadXML CONTOP
.appendChild .createElement("SOAP:Body")
'.documentElement.appendChild .createElement("SOAP:Body")
End With

Exit Sub

Handle_Error:
Err.Raise Err.Number, "Class_Initialize: " & _
Err.Source, Err.Description
End Sub

Private Sub Class_Terminate()
Set XMLDOC = Nothing
End Sub

Public Property Get NamespaceURI() As String
NamespaceURI = mstrNameSpace
End Property

Public Property Let NamespaceURI(ByVal URI As String)
mstrNameSpace = URI

End Property

Public Sub AddFault(ByVal FaultCode As String, _
ByVal FaultString As String)
Dim xmlNode As MSXML2.IXMLDOMNode
Dim xmlElem As MSXML2.IXMLDOMElement

Set xmlNode = XMLDOC.documentElement. _
selectSingleNode("SOAP:Body")

'If there is not already a fault section, create it.
If xmlNode.selectNodes("SOAP:Fault").length = 0 Then
xmlNode.appendChild XMLDOC.createElement("SOAP:Fault")
End If

Set xmlElem = XMLDOC.createElement("faultcode")
xmlElem.Text = FaultCode
xmlNode.selectSingleNode("SOAP:Fault").appendChild xmlElem

Set xmlElem = XMLDOC.createElement("faultstring")
xmlElem.Text = FaultString
xmlNode.selectSingleNode("SOAP:Fault").appendChild xmlElem

Exit Sub

Handle_Error:
Err.Raise Err.Number, "AddFault: " & Err.Source, _
Err.Description
End Sub

Public Sub AddFaultDetail(ByVal Number As String, _
ByVal Source As String, ByVal Description As String)
Dim xmlNode As MSXML2.IXMLDOMNode
Dim xmlElem As MSXML2.IXMLDOMElement

Set xmlNode = XMLDOC.documentElement. _
selectSingleNode("SOAP:Body")

'If there is not already a fault section, create it.
If xmlNode.selectNodes("SOAP:Fault").length = 0 Then
xmlNode.appendChild XMLDOC.createElement("SOAP:Fault")
End If

Set xmlNode = xmlNode.selectSingleNode("SOAP:Fault").appendChild _
(XMLDOC.createElement("detail"))

Set xmlElem = XMLDOC.createElement("number")
xmlElem.Text = Number
xmlNode.appendChild xmlElem

Set xmlElem = XMLDOC.createElement("source")
xmlElem.Text = Source
xmlNode.appendChild xmlElem

Set xmlElem = XMLDOC.createElement("description")
xmlElem.Text = Description
xmlNode.appendChild xmlElem

Exit Sub

Handle_Error:
Err.Raise Err.Number, "AddFaultDetail: " & _
Err.Source, Err.Description
End Sub

Reply With Quote
  #4  
Old October 21st, 2003, 09:49 PM
wes wes is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 24 wes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try this, defining the object name when passing an object to selectSingleNode(). You define the name in the With statement below your error causing code, so if it works, this may work.

Code:
With XMLDOC 
Set xmlNode = .createNode(NODE_ELEMENT, Class & _ 
":" & Method, NS) 
.selectSingleNode("SOAP:Envelope/SOAP:Body") _ 
XMLDOC.appendChild xmlNode 
End With 


Or try not using a With statement, but explicitly defining the name always where needed.

Code:
Set xmlNode = XMLDOC.createNode(NODE_ELEMENT, Class & _ 
":" & Method, NS) 
XMLDOC.selectSingleNode("SOAP:Envelope/SOAP:Body") _ XMLDOC.appendChild xmlNode 

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Object variable or With block variable not set (Error 91)


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap