943,834 Members | Top Members by Rank

Jun 10th, 2008
0

SOAP Request/Response Issue

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
CJL1980 is offline Offline
2 posts
since Jun 2008
Jun 10th, 2008
0

Re: SOAP Request/Response Issue

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
CJL1980 is offline Offline
2 posts
since Jun 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in RSS, Web Services and SOAP Forum Timeline: pls Help!! how to search for string in a file with C# and Web Services??
Next Thread in RSS, Web Services and SOAP Forum Timeline: right XML request for WSDL





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC