Hi,
First thing is first, I wasnt sure whether to put this in this section or in the VB.NET section as it has aspects of both but I decided the issue was probably more relevent to this section so here it is.
Secondly this question may seem trivial (any question is trivial if you know the answer I guess) so please bear with me as I am new to XML and hadn't even heard of SOAP until yesterday and this is pretty much the issue here I think.
OK down to business, I have to send a SOAP request to consume a webserve and get a response back. I am using System.Net.HttpWebRequest and System.Net.HttpWebResponse classes to send/recieve the SOAP objects.
The issue is that I can not seem to get it to return anything. When I run the console app in debug mode it gets to the objHTTPReq.GetResponse() method and then stalls.
It is not causing an Exception as I have a try/catch arround the block (see the code below). I have been working away at this for almost 5 hours now and getting nowhere. Another thing that could be causing the issue is that I may not be calling a service that is working (I asked my friend Google for a list of public services and picked a simple one to test the console app).
The bottom line is that I know that little about this that I could just be using the wrong URL and/or entering the wrong parameters in the wrong order etc etc.
Any help would be appreciated.
The code is shown below:
Public Function xxxxxxxxx()
Dim soapMessage As String
Dim objHTTPReq As System.Net.HttpWebRequest
Dim objHTTPRes As System.Net.HttpWebResponse
Try
objHTTPReq = CType(System.Net.WebRequest.CreateDefault(New System.Uri("http://euro2008.dataaccess.eu/footballpoolwebservice.wso")), HttpWebRequest)
objHTTPReq.ContentType = "text/xml;charset=""utf-8"""
objHTTPReq.Method = "POST"
objHTTPReq.Accept = "text/xml"
' CREDENTIALS TO BE ARANGED objHTTPReq.Credentials = (New NetworkCredential("username", "password", "domain"))
'SOAPAction header
objHTTPReq.Headers.Add("SOAPAction", """http://euro2008.dataaccess.eu/footballpoolwebservice/AllPlayerNames""")
soapMessage = "<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><AllPlayerNames xmlns='http://euro2008.dataaccess.eu'></AllPlayerNames></soap:Body></soap:Envelope>"
'Send the XML Request
Dim objStream As System.IO.StreamWriter
objStream = New StreamWriter(objHTTPReq.GetRequestStream(), Encoding.UTF8)
objStream.Write(soapMessage)
objHTTPRes = objHTTPReq.GetResponse()
''''And you can display or process the XML
Dim objXML As New System.Xml.XmlDocument()
objXML.Load(objHTTPRes.GetResponseStream())
Return objXML
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Function
The info on the service I am tring to communicate with is below:
Service Name: AllPlayerNames
Reqest:
POST /footballpoolwebservice.wso HTTP/1.1
Host: euro2008.dataaccess.eu
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AllPlayerNames xmlns="http://euro2008.dataaccess.eu">
</AllPlayerNames>
</soap:Body>
</soap:Envelope>
Response:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AllPlayerNamesResponse xmlns="http://euro2008.dataaccess.eu">
<AllPlayerNamesResult>
<string>string</string>
<string>string</string>
</AllPlayerNamesResult>
</AllPlayerNamesResponse>
</soap:Body>
</soap:Envelope>
Any help would be hugely appreciated.
Cheers,
CJL.