472,378 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 11170
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dan Sikorsky | last post by:
Uploading from browser to server using Msxml2.XMLHTTP takes a long time about 15 minutes for a 1.5MB file at 37.2Kbps, although it does get there. Is there anyway to speed things up? here's the...
17
by: Patrick | last post by:
I am almost certain that I could use HTTP Post/Get to submit XML Web Service call (over SSL as well, if using Version 3 of MSXML2) from an ASP Application? However, would I only be able to call...
5
by: RK | last post by:
I am getting the "HTTP /1.1 405 - method not allowed" error when I am sending XML string over Msxml2.XMLHTTP object. I am sending data in POST, also passing querystring variable and here is the...
2
by: Michael Christensen | last post by:
Hi How do I send an input-param to my web service with MSXML2.ServerXMLHTTP? Can this be done without the soap-toolkit? Can't find anything about it - looking forward getting some help :-)...
1
by: Raúl Martín | last post by:
I´ve a function in asp that run correctly but If I tried to change it forasp.net in asp: xmlHTTP = CreateObject("Microsoft.XMLHTTP") And I thought to use this sentence for asp.net but the...
2
by: Maris Janis Vasilevskis | last post by:
Hi, Is it possible to force HttpWebRequest to do exactly (not approximately) the same as MSXML2.ServerXMLHTTP does? More details. I port JScript to JScript.NET I have a server (ASP invoking...
5
by: Brent | last post by:
This AJAX stuff is all new to me. To try it out, I borrowed this code from a website: ======================== var http_request = false; function makeRequest(url) { http_request = false;
2
by: noOby | last post by:
Hi developers, currently i'm doing a school project and i am stuck on MSXML2.XMLHTTP conversion from vb code to c#. Below is the vb Coding that i need to convert to C# Dim sUrl As String ...
2
by: Dave | last post by:
I am running the following code and I get an error: Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.3.0") xmlHttp.Open "Get", URLToRSS, false xmlHttp.Send RSSXML = xmlHttp.ResponseText The...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

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.