469,631 Members | 980 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

DotNet WS from VB6 with MSXML2.XMLHTTP

I'm trying to consume a WS from Excel (Office 98), seems that I can't
send arguments into the WS. In order to pinpoint the problem I've
written the following application i C# and VB6. It reproduces exaclty
the same problem with less code. Any hints on how to solve this would be
greatly appreciated. /Regards Björn

The webservice is:

using System;
using System.Web.Services;

[WebService(Namespace="http://tempuri.org/")]
public class DotNetWS : WebService {
[WebMethod]
public string ReturnArgument(string Argument) {
return Argument;
//return "We can't get Argument into WS!";
}
}

And this is the client:

Private Sub Command1_Click()
Dim mhttp As MSXML2.XMLHTTP
Dim s As String

Set mhttp = New MSXML2.XMLHTTP
mhttp.open "Post", "http://localhost/DotNetWS/DotNetWS.asmx", False
mhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
mhttp.setRequestHeader "SoapAction",
"http://tempuri.org/ReturnArgument"

s = s & "<?xml version=""1.0"" encoding=""UTF-8""?>"
s = s & "<soap:Envelope
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
s = s & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "
s = s & "xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
s = s & "<soap:Body>"
s = s & "<ReturnArgument xmlns=""http://tempuri.org"">"
s = s & "<Argument>Easy go, easy come back?</Argument>"
s = s & "</ReturnArgument>"
s = s & "</soap:Body>"
s = s & "</soap:Envelope>"

mhttp.send s
MsgBox mhttp.responseText
End Sub
Nov 21 '05 #1
3 11043
Hi Björn,
I was able to make it work with a few adjustments. You'll need to change the
URL and the namespaces that are for my system:

Private Sub Command1_Click()
Dim mhttp As MSXML2.XMLHTTP
Dim s As String
Set mhttp = CreateObject("MSXML2.XMLHTTP")
mhttp.Open _
"POST", "http://p4320/p4320work/args.asmx", False, "", ""
mhttp.setRequestHeader "SOAPAction", _
"http://tempuri.org/p4320work/args/ReturnArgument"
mhttp.setRequestHeader "Content-Type", "text/xml"
s = s & "<?xml version=""1.0"" encoding=""UTF-8""?>"
s = s & "<soap:Envelope
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
s = s & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "
s = s & "xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
s = s & "<soap:Body>"
s = s & "<ReturnArgument xmlns=""http://tempuri.org/p4320work/args"">"
s = s & "<Argument>Easy go, easy come back?</Argument>"
s = s & "</ReturnArgument>"
s = s & "</soap:Body>"
s = s & "</soap:Envelope>"
mhttp.send s
Debug.Print mhttp.responseText
End Sub
"BjörnHolmberg" <bj************************@sulitelma.com> wrote in message
news:40***************@sulitelma.com...
I'm trying to consume a WS from Excel (Office 98), seems that I can't
send arguments into the WS. In order to pinpoint the problem I've
written the following application i C# and VB6. It reproduces exaclty
the same problem with less code. Any hints on how to solve this would be
greatly appreciated. /Regards Björn

The webservice is:

using System;
using System.Web.Services;

[WebService(Namespace="http://tempuri.org/")]
public class DotNetWS : WebService {
[WebMethod]
public string ReturnArgument(string Argument) {
return Argument;
//return "We can't get Argument into WS!";
}
}

And this is the client:

Private Sub Command1_Click()
Dim mhttp As MSXML2.XMLHTTP
Dim s As String

Set mhttp = New MSXML2.XMLHTTP
mhttp.open "Post", "http://localhost/DotNetWS/DotNetWS.asmx", False
mhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
mhttp.setRequestHeader "SoapAction",
"http://tempuri.org/ReturnArgument"

s = s & "<?xml version=""1.0"" encoding=""UTF-8""?>"
s = s & "<soap:Envelope
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
s = s & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "
s = s & "xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
s = s & "<soap:Body>"
s = s & "<ReturnArgument xmlns=""http://tempuri.org"">"
s = s & "<Argument>Easy go, easy come back?</Argument>"
s = s & "</ReturnArgument>"
s = s & "</soap:Body>"
s = s & "</soap:Envelope>"

mhttp.send s
MsgBox mhttp.responseText
End Sub


Nov 21 '05 #2
Hello Ken! I've found the problem, it was a trailing slash in the namespace declaration of WS, that
was not in the <ReturnArgument>-element of client. A bunch of thanks to You, without your reply I
would still be out in the (be-)wilderness. /Björn

"Ken Cox [Microsoft MVP]" wrote:
Hi Björn,
I was able to make it work with a few adjustments. You'll need to change the
URL and the namespaces that are for my system:

Private Sub Command1_Click()
Dim mhttp As MSXML2.XMLHTTP
Dim s As String
Set mhttp = CreateObject("MSXML2.XMLHTTP")
mhttp.Open _
"POST", "http://p4320/p4320work/args.asmx", False, "", ""
mhttp.setRequestHeader "SOAPAction", _
"http://tempuri.org/p4320work/args/ReturnArgument"
mhttp.setRequestHeader "Content-Type", "text/xml"
s = s & "<?xml version=""1.0"" encoding=""UTF-8""?>"
s = s & "<soap:Envelope
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
s = s & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "
s = s & "xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
s = s & "<soap:Body>"
s = s & "<ReturnArgument xmlns=""http://tempuri.org/p4320work/args"">"
s = s & "<Argument>Easy go, easy come back?</Argument>"
s = s & "</ReturnArgument>"
s = s & "</soap:Body>"
s = s & "</soap:Envelope>"
mhttp.send s
Debug.Print mhttp.responseText
End Sub

"BjörnHolmberg" <bj************************@sulitelma.com> wrote in message
news:40***************@sulitelma.com...
I'm trying to consume a WS from Excel (Office 98), seems that I can't
send arguments into the WS. In order to pinpoint the problem I've
written the following application i C# and VB6. It reproduces exaclty
the same problem with less code. Any hints on how to solve this would be
greatly appreciated. /Regards Björn

The webservice is:

using System;
using System.Web.Services;

[WebService(Namespace="http://tempuri.org/")]
public class DotNetWS : WebService {
[WebMethod]
public string ReturnArgument(string Argument) {
return Argument;
//return "We can't get Argument into WS!";
}
}

And this is the client:

Private Sub Command1_Click()
Dim mhttp As MSXML2.XMLHTTP
Dim s As String

Set mhttp = New MSXML2.XMLHTTP
mhttp.open "Post", "http://localhost/DotNetWS/DotNetWS.asmx", False
mhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
mhttp.setRequestHeader "SoapAction",
"http://tempuri.org/ReturnArgument"

s = s & "<?xml version=""1.0"" encoding=""UTF-8""?>"
s = s & "<soap:Envelope
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
s = s & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "
s = s & "xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
s = s & "<soap:Body>"
s = s & "<ReturnArgument xmlns=""http://tempuri.org"">"
s = s & "<Argument>Easy go, easy come back?</Argument>"
s = s & "</ReturnArgument>"
s = s & "</soap:Body>"
s = s & "</soap:Envelope>"

mhttp.send s
MsgBox mhttp.responseText
End Sub


Nov 21 '05 #3
Hi Björn,

Glad to hear you're running again!

Why don't computers tell us when we're missing something simple - or better
yet, just fix it? <grin>

Ken

"BjörnHolmberg" <bj*****************************@sulitelma.com> wrote in
message news:40***************@sulitelma.com...
Hello Ken! I've found the problem, it was a trailing slash in the
namespace declaration of WS, that
was not in the <ReturnArgument>-element of client. A bunch of thanks to
You, without your reply I
would still be out in the (be-)wilderness. /Björn

"Ken Cox [Microsoft MVP]" wrote:
Hi Björn,
I was able to make it work with a few adjustments. You'll need to change
the
URL and the namespaces that are for my system:

Private Sub Command1_Click()
Dim mhttp As MSXML2.XMLHTTP
Dim s As String
Set mhttp = CreateObject("MSXML2.XMLHTTP")
mhttp.Open _
"POST", "http://p4320/p4320work/args.asmx", False, "", ""
mhttp.setRequestHeader "SOAPAction", _
"http://tempuri.org/p4320work/args/ReturnArgument"
mhttp.setRequestHeader "Content-Type", "text/xml"
s = s & "<?xml version=""1.0"" encoding=""UTF-8""?>"
s = s & "<soap:Envelope
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
s = s & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "
s = s & "xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
s = s & "<soap:Body>"
s = s & "<ReturnArgument xmlns=""http://tempuri.org/p4320work/args"">"
s = s & "<Argument>Easy go, easy come back?</Argument>"
s = s & "</ReturnArgument>"
s = s & "</soap:Body>"
s = s & "</soap:Envelope>"
mhttp.send s
Debug.Print mhttp.responseText
End Sub

"BjörnHolmberg" <bj************************@sulitelma.com> wrote in
message
news:40***************@sulitelma.com...
> I'm trying to consume a WS from Excel (Office 98), seems that I can't
> send arguments into the WS. In order to pinpoint the problem I've
> written the following application i C# and VB6. It reproduces exaclty
> the same problem with less code. Any hints on how to solve this would
> be
> greatly appreciated. /Regards Björn
>
> The webservice is:
>
> using System;
> using System.Web.Services;
>
> [WebService(Namespace="http://tempuri.org/")]
> public class DotNetWS : WebService {
> [WebMethod]
> public string ReturnArgument(string Argument) {
> return Argument;
> //return "We can't get Argument into WS!";
> }
> }
>
> And this is the client:
>
> Private Sub Command1_Click()
> Dim mhttp As MSXML2.XMLHTTP
> Dim s As String
>
> Set mhttp = New MSXML2.XMLHTTP
> mhttp.open "Post", "http://localhost/DotNetWS/DotNetWS.asmx", False
> mhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
> mhttp.setRequestHeader "SoapAction",
> "http://tempuri.org/ReturnArgument"
>
> s = s & "<?xml version=""1.0"" encoding=""UTF-8""?>"
> s = s & "<soap:Envelope
> xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
> s = s & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" "
> s = s & "xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
> s = s & "<soap:Body>"
> s = s & "<ReturnArgument xmlns=""http://tempuri.org"">"
> s = s & "<Argument>Easy go, easy come back?</Argument>"
> s = s & "</ReturnArgument>"
> s = s & "</soap:Body>"
> s = s & "</soap:Envelope>"
>
> mhttp.send s
> MsgBox mhttp.responseText
> End Sub
>
>


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Maris Janis Vasilevskis | last post: by
2 posts views Thread by noOby | last post: by
2 posts views Thread by Dave | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.