473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SOAP Client working but need some more functionality

Hello.
I've just coded a VBScript SOAP Client to send requests to a web
service in our intranet. It's working and we'll use it in a DTS cuz we
have not implemented SQL Server 2005 yet. Anyway. I need some more
functionality. For example with the script below I'm able to get the
Session ID Token from our web service and save the full SOAP xml
Envelope to a file. But What if for example I want to save certain
nodes I receive in the response?? I set it up so that I can use DOM,
been trying to do that but I'm getting errors.

If you have any tips they will be much appreciated.

Regards.

Martin
mo******@gmail.com

Option Explicit

'Variables for the SOAP Call
Dim xmlhttp
Set xmlhttp = CreateObject("Msxml2.XMLHTTP")
Dim xmldoc
Set xmldoc = CreateObject("Msxml2.DOMDocument.4.0")
Dim strUrl, strRequest
strUrl = "http://nn.nn.com/nn"

'Variables for saving the Session ID
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText
strDirectory = "C:\Sample"
strFile = "\LoginSessionID.txt"
strRequest = "<?xml version=""1.0"" encoding=""utf-8""?>" & _
"<soapenv:Envelope xmlns:xsi=""http://www.w3.org/2001/
XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/""
xmlns:ser=""http://nn.nn.nn.com"">" & _
"<soapenv:Header/>" & _
"<soapenv:Body>" & _
"<ser:login soapenv:encodingStyle=""http://
schemas.xmlsoap.org/soap/encoding/"">" & _
"<version xsi:type=""xsd:string"">63</version>" & _
"<user xsi:type=""xsd:string"">nn_test</user>" & _
"<password xsi:type=""xsd:string"">nn_Pwd</password>" & _
"</ser:login>" & _
"</soapenv:Body>" & _
"</soapenv:Envelope>"

With xmlhttp
.Open "post", strUrl, False
.setRequestHeader "content-type", "text/xml; charset=utf-8"
.setRequestHeader "SOAPAction", "http://nn.nn.nn.com/login"
.send strRequest

'Here I echo out the response for testing porpuses - it's
working ok

wscript.echo .responseXML.xml

'Here I place the reponse in the variable strText - it's
working ok - But what if I want to place just one element of the SOAP
envelope in the variable, for example the session ID number with
getting rid of all xml tags?

strText = .responseXML.xml

End With

'The rest of the script is working ok. I mean it saves the Web Service
XML response to a file.
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
Wscript.Echo "Just created " & strDirectory & strFile
End If

set objFile = nothing
set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8

Set objTextFile = objFSO.OpenTextFile _
(strDirectory & strFile, ForAppending, True)

' Writes strText
objTextFile.WriteLine(strText)
objTextFile.Close

' I'll remove this part after we finish prototyping
If err.number = vbEmpty then
Set objShell = CreateObject("WScript.Shell")
objShell.run ("Explorer" &" " & strDirectory & "\" )
Else WScript.echo "VBScript Error: " & err.number
End If

WScript.Quit

' End of VBScript
Aug 6 '08 #1
1 4178


<mo******@gmail.comwrote in message
news:65**********************************@m73g2000 hsh.googlegroups.com...
Hello.
I've just coded a VBScript SOAP Client to send requests to a web
service in our intranet. It's working and we'll use it in a DTS cuz we
have not implemented SQL Server 2005 yet. Anyway. I need some more
functionality. For example with the script below I'm able to get the
Session ID Token from our web service and save the full SOAP xml
Envelope to a file. But What if for example I want to save certain
nodes I receive in the response?? I set it up so that I can use DOM,
been trying to do that but I'm getting errors.

If you have any tips they will be much appreciated.

Regards.

Martin
mo******@gmail.com

Option Explicit

'Variables for the SOAP Call
Dim xmlhttp
Set xmlhttp = CreateObject("Msxml2.XMLHTTP")
Dim xmldoc
Set xmldoc = CreateObject("Msxml2.DOMDocument.4.0")
Dim strUrl, strRequest
strUrl = "http://nn.nn.com/nn"

'Variables for saving the Session ID
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText
strDirectory = "C:\Sample"
strFile = "\LoginSessionID.txt"
strRequest = "<?xml version=""1.0"" encoding=""utf-8""?>" & _
"<soapenv:Envelope xmlns:xsi=""http://www.w3.org/2001/
XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/""
xmlns:ser=""http://nn.nn.nn.com"">" & _
"<soapenv:Header/>" & _
"<soapenv:Body>" & _
"<ser:login soapenv:encodingStyle=""http://
schemas.xmlsoap.org/soap/encoding/"">" & _
"<version xsi:type=""xsd:string"">63</version>" & _
"<user xsi:type=""xsd:string"">nn_test</user>" & _
"<password xsi:type=""xsd:string"">nn_Pwd</password>" & _
"</ser:login>" & _
"</soapenv:Body>" & _
"</soapenv:Envelope>"

With xmlhttp
.Open "post", strUrl, False
.setRequestHeader "content-type", "text/xml; charset=utf-8"
.setRequestHeader "SOAPAction", "http://nn.nn.nn.com/login"
.send strRequest

'Here I echo out the response for testing porpuses - it's
working ok

wscript.echo .responseXML.xml

'Here I place the reponse in the variable strText - it's
working ok - But what if I want to place just one element of the SOAP
envelope in the variable, for example the session ID number with
getting rid of all xml tags?

strText = .responseXML.xml

End With

'The rest of the script is working ok. I mean it saves the Web Service
XML response to a file.
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
Wscript.Echo "Just created " & strDirectory & strFile
End If

set objFile = nothing
set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8

Set objTextFile = objFSO.OpenTextFile _
(strDirectory & strFile, ForAppending, True)

' Writes strText
objTextFile.WriteLine(strText)
objTextFile.Close

' I'll remove this part after we finish prototyping
If err.number = vbEmpty then
Set objShell = CreateObject("WScript.Shell")
objShell.run ("Explorer" &" " & strDirectory & "\" )
Else WScript.echo "VBScript Error: " & err.number
End If

WScript.Quit

' End of VBScript
You can either use selectSingleNode from the responseXML directly or load
into a fresh DOM
Dim oDom
Dim bLoaded
Set oDom = CreateObject("msxml.domdocument.6.0")
bLoaded = oDom.load(xmlhttp.responseXML)
oDom.setProperty "SelectionNamespaces",
"xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:ser='http://nn.nn.nn.com'"
Then select your node(s) using the prefixes defined to qualify element
names. e.g.
soapenv:envelope/soapenv:Body

--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name

Aug 7 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Glauco | last post by:
I'm trying to use SOAPpy 0.10.1 for a client but is difficult to handle easly Is this library in use or i'm using an OLD death library ? I'm alone in find a lot of problem in a SOAP Client ?...
2
by: Tomislav Lepusic | last post by:
Hello, I don't know if this is the right group (I'm more in Perl, know nothing about Python), so if you can help me thanks, if not, sorry to bother you. I'm working on my student project and...
4
by: Jonas Hei | last post by:
I've noticed that one can use IE to test web pages (by going on http://hostname/blah/blah.asmx - and then it shows a list of methods supported by the webservice, and on selecting each method once...
0
by: Grzegorz Smith | last post by:
Hi All. I 'm learning ZSI to use SOAP and I desperately need help. I'm working on example from tutorial -(examples/server/send_response/ simple/wsdl/). Here are my wsdl files...
6
by: Joseph Geretz | last post by:
I have the following class which I am serializing and passing back and forth between my Web Service application and the client. public class Token : SoapHeader { public string SID; public...
15
by: =?Utf-8?B?ZG91Zw==?= | last post by:
I hadn't had a class yet and I had some MS help on this to set up, but I wrote a .Net WS that creates a proxy class response using SOAP. Works fine. And in kind of a good way, the IDE has hidden...
4
by: wbsurfver | last post by:
I have been trying to figure out apache/rampart soap security. We have a soap server in java and the client is PHP. I just read this article which concerns me because it seems to imply rampart/java...
5
by: =?Utf-8?B?SmltbWVy?= | last post by:
Hello, I've been trying to create a WCF SOAP Router Service that can forward not just the message body but also any security headers set by the originator of the message. The destination service...
5
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I've got a .Net client to a soap service that works for the most part, but there are a couple of things I'd like to improve: 1) the first request to the client wrapper always takes...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.