SOAP Request/Response Issue

Please support our RSS, Web Services and SOAP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Jun 2008
Posts: 2
Reputation: CJL1980 is an unknown quantity at this point 
Solved Threads: 0
CJL1980 CJL1980 is offline Offline
Newbie Poster

SOAP Request/Response Issue

 
0
  #1
Jun 10th, 2008
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:

RSS, Web Services and SOAP Syntax (Toggle Plain Text)
  1. Public Function xxxxxxxxx()
  2. Dim soapMessage As String
  3. Dim objHTTPReq As System.Net.HttpWebRequest
  4. Dim objHTTPRes As System.Net.HttpWebResponse
  5. Try
  6. objHTTPReq = CType(System.Net.WebRequest.CreateDefault(New System.Uri("http://euro2008.dataaccess.eu/footballpoolwebservice.wso")), HttpWebRequest)
  7. objHTTPReq.ContentType = "text/xml;charset=""utf-8"""
  8. objHTTPReq.Method = "POST"
  9. objHTTPReq.Accept = "text/xml"
  10. ' CREDENTIALS TO BE ARANGED objHTTPReq.Credentials = (New NetworkCredential("username", "password", "domain"))
  11.  
  12.  
  13. 'SOAPAction header
  14.  
  15. objHTTPReq.Headers.Add("SOAPAction", """http://euro2008.dataaccess.eu/footballpoolwebservice/AllPlayerNames""")
  16.  
  17. 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>"
  18. 'Send the XML Request
  19.  
  20. Dim objStream As System.IO.StreamWriter
  21. objStream = New StreamWriter(objHTTPReq.GetRequestStream(), Encoding.UTF8)
  22. objStream.Write(soapMessage)
  23. objHTTPRes = objHTTPReq.GetResponse()
  24.  
  25. ''''And you can display or process the XML
  26.  
  27. Dim objXML As New System.Xml.XmlDocument()
  28. objXML.Load(objHTTPRes.GetResponseStream())
  29. Return objXML
  30. Catch ex As Exception
  31. Console.WriteLine(ex.Message)
  32. End Try
  33. End Function

The info on the service I am tring to communicate with is below:

RSS, Web Services and SOAP Syntax (Toggle Plain Text)
  1. Service Name: AllPlayerNames
  2.  
  3.  
  4. Reqest:
  5.  
  6.  
  7. POST /footballpoolwebservice.wso HTTP/1.1
  8. Host: euro2008.dataaccess.eu
  9. Content-Type: text/xml; charset=utf-8
  10. Content-Length: length
  11.  
  12. <?xml version="1.0" encoding="utf-8"?>
  13. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  14. <soap:Body>
  15. <AllPlayerNames xmlns="http://euro2008.dataaccess.eu">
  16. </AllPlayerNames>
  17. </soap:Body>
  18. </soap:Envelope>
  19.  
  20.  
  21. Response:
  22.  
  23.  
  24. HTTP/1.1 200 OK
  25. Content-Type: text/xml; charset=utf-8
  26. Content-Length: length
  27.  
  28. <?xml version="1.0" encoding="utf-8"?>
  29. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  30. <soap:Body>
  31. <AllPlayerNamesResponse xmlns="http://euro2008.dataaccess.eu">
  32. <AllPlayerNamesResult>
  33. <string>string</string>
  34. <string>string</string>
  35. </AllPlayerNamesResult>
  36. </AllPlayerNamesResponse>
  37. </soap:Body>
  38. </soap:Envelope>

Any help would be hugely appreciated.

Cheers,

CJL.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 2
Reputation: CJL1980 is an unknown quantity at this point 
Solved Threads: 0
CJL1980 CJL1980 is offline Offline
Newbie Poster

Re: SOAP Request/Response Issue

 
0
  #2
Jun 10th, 2008
Sorry to have bothered you I figured it out and the problem was irritatingly simple.

I had forgotten the line:

RSS, Web Services and SOAP Syntax (Toggle Plain Text)
  1. objStream.close()

This meant there were no streams available to get the response.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC