423,851 Members | 2,762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,851 IT Pros & Developers. It's quick & easy.

sending soap over http

P: n/a
i have a very simple web servive

Imports System.Web.Services

<System.Web.Services.WebService(Namespace:="urn:Ex ample1")> _

Public Class Example1

Inherits System.Web.Services.WebService


<WebMethod()> _

Public Function HelloWorld(ByVal name As String) As String

Return "Hello " & name

End Function

End Class

I have a VB Script with which I'm trying to send a soap message with. When
i execute i get to the input soap message message box showing me the
message, but when i click ok, it seems to hang. i have to kill the script
through taskmgr. this is on windows 2000.

Any ideas why it wouldn't return?

Dim x, h
Set x = CreateObject("MSXML2.DOMDocument")
x.loadXML "<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/1999/XMLSchema'><s:Body><m:sayHello
xmlns:m='urn:Example1'><name
xsi:type='xsd:string'>James</name></m:sayHello></s:Body></s:Envelope>"

msgbox x.xml, , "Input SOAP Message"
Set h = CreateObject("Microsoft.XMLHTTP")
h.open "POST", "http://localhost/HelloWorld/Service1.asmx"
h.send (x)
while h.readyState <> 4
wend
msgbox h.responseText,,"Output SOAP Message"

Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Correction:

I had to change the word sayHello to Helloworld, since that is my method
name.

Dim x, h,r, s, t, u, v,z

Set x = CreateObject("MSXML2.DOMDocument")

s ="<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'"
t = " xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'"
u = " xmlns:xsd='http://www.w3.org/1999/XMLSchema'>"
v = " <s:Body><m:HelloWorld xmlns:m='urn:Example1'>"
r = " <name
xsi:type='xsd:string'>James</name></m:HelloWorld></s:Body></s:Envelope>"

z= s & t & u & v & r

x.loadXML z
msgbox x.xml, , "Input SOAP Message"
Set h = CreateObject("Microsoft.XMLHTTP")
h.open "POST", "http://localhost/HelloWorld/Service1.asmx"
h.send (x)
while h.readyState <> 4
wend
msgbox h.responseText,,"Output SOAP Message"
"Mark" <ma*********@acordia.com> wrote in message
news:ed**************@TK2MSFTNGP14.phx.gbl...
i have a very simple web servive

Imports System.Web.Services

<System.Web.Services.WebService(Namespace:="urn:Ex ample1")> _

Public Class Example1

Inherits System.Web.Services.WebService


<WebMethod()> _

Public Function HelloWorld(ByVal name As String) As String

Return "Hello " & name

End Function

End Class

I have a VB Script with which I'm trying to send a soap message with. When i execute i get to the input soap message message box showing me the
message, but when i click ok, it seems to hang. i have to kill the script
through taskmgr. this is on windows 2000.

Any ideas why it wouldn't return?

Dim x, h
Set x = CreateObject("MSXML2.DOMDocument")
x.loadXML "<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/1999/XMLSchema'><s:Body><m:sayHello
xmlns:m='urn:Example1'><name
xsi:type='xsd:string'>James</name></m:sayHello></s:Body></s:Envelope>"

msgbox x.xml, , "Input SOAP Message"
Set h = CreateObject("Microsoft.XMLHTTP")
h.open "POST", "http://localhost/HelloWorld/Service1.asmx"
h.send (x)
while h.readyState <> 4
wend
msgbox h.responseText,,"Output SOAP Message"

Nov 12 '05 #2

P: n/a
I'm getting close.. It appears something is wrong with my soap message
itself. I'm using the
HttpWebRequest and HttpWebResponse objects to send/receive this data.
Any help would be much appreciated.

-----------------------------------------------------------------
I have a string which contains the following data.

"<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/1999/XMLSchema'>
<s:Body><m:HelloWorld xmlns:m='urn:Example1'>
<name
xsi:type='xsd:string'>James</name></m:HelloWorld></s:Body></s:Envelope>"

-----------------------------------------------------------------
The web service i'm sending this to is

Imports System.Web.Services

<System.Web.Services.WebService(Namespace:="urn:Ex ample1")> _

Public Class Example1

Inherits System.Web.Services.WebService

<WebMethod()> _

Public Function HelloWorld(ByVal name As String) As String

Return "Hello " & name

End Function

End Class

-----------------------------------------------------------------
The error I'm getting is
<?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>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unable to handle request without a valid action
parameter. Please supply a valid soap action.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
Nov 12 '05 #3

P: n/a


Mark wrote:
It appears something is wrong with my soap message
itself. I'm using the
HttpWebRequest and HttpWebResponse objects to send/receive this data.
Why? If you are using .NET (as HttpWebRequest suggests) then simply
create a proxy class to use the web service, .NET has a tool called
wsdl.exe to do exactly that to avoid anyone having to deal with SOAP
itself (which is complex). The wsdl.exe tool reads the WSDL file
describing the web service and generates .NET source code for a proxy
class which you can compile and then include in your .NET project to
easily access the web service transparently calling methods on the proxy
without ever dealing with SOAP.

As for your earlier message that looked like you were using VBScript,
even there MS has a toolkit named SOAP toolkit that helps you with
accessing web services without the need to construct the raw SOAP from
hand. Look on http://msdn.microsoft.com/ for SOAP toolkit, download it
and check the examples on how to build a SOAP client with script.
The error I'm getting is
<?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>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unable to handle request without a valid action
parameter. Please supply a valid soap action.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>


Well SOAP over HTTP needs a custom HTTP header named SOAPAction which
(untested and written from memory) needs to be alike

SOAPAction: urn:Example1/HelloWorld

for your web service so if you really want to use HttpWebRequest or
Msmxl2.XMLHTTP to access a web service then you need to make sure you
set that HTTP header (not SOAP header!) before sending your request.

But as said, there are tools with both COM based application (like VB or
VBScript or JScript) and .NET to free you from thinking about that
stuff, you simply call a method and get a result in the language of your
choice and the whole SOAP creation and parsing is done by the tools
reading the WSDL description of the web service.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #4

P: n/a
That is part of my problem and why I am lost.

I've been told by the folks that developed this web service that they are
not using WSDL.
I've used the soap toolkit in the past with VB 6.0 and it was very easy.

I was told i had to generate these "raw" soap message to send to this
service. I spoke with another person yesterday who sent data to this
service and they stated that they wrote out the xml doc line by line in code
and then sent it.

That is why i'm trying to understand how to write a soap message manually.

thank you for the suggestions.
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:ud**************@TK2MSFTNGP09.phx.gbl...


Mark wrote:
It appears something is wrong with my soap message
itself. I'm using the
HttpWebRequest and HttpWebResponse objects to send/receive this data.


Why? If you are using .NET (as HttpWebRequest suggests) then simply
create a proxy class to use the web service, .NET has a tool called
wsdl.exe to do exactly that to avoid anyone having to deal with SOAP
itself (which is complex). The wsdl.exe tool reads the WSDL file
describing the web service and generates .NET source code for a proxy
class which you can compile and then include in your .NET project to
easily access the web service transparently calling methods on the proxy
without ever dealing with SOAP.

As for your earlier message that looked like you were using VBScript,
even there MS has a toolkit named SOAP toolkit that helps you with
accessing web services without the need to construct the raw SOAP from
hand. Look on http://msdn.microsoft.com/ for SOAP toolkit, download it
and check the examples on how to build a SOAP client with script.
The error I'm getting is
<?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>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unable to handle request without a valid action
parameter. Please supply a valid soap action.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>


Well SOAP over HTTP needs a custom HTTP header named SOAPAction which
(untested and written from memory) needs to be alike

SOAPAction: urn:Example1/HelloWorld

for your web service so if you really want to use HttpWebRequest or
Msmxl2.XMLHTTP to access a web service then you need to make sure you
set that HTTP header (not SOAP header!) before sending your request.

But as said, there are tools with both COM based application (like VB or
VBScript or JScript) and .NET to free you from thinking about that
stuff, you simply call a method and get a result in the language of your
choice and the whole SOAP creation and parsing is done by the tools
reading the WSDL description of the web service.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.