Advertisement
| Hall of Fame |
|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: |
Private Function ExecuteXmlRequest(ByVal requestXmlDoc As XmlDocument) As XmlDocument
Dim responseXmlDoc As New XmlDocument
Dim responseData As [String] = [String].Empty ' String to store the response ASCII representation.
Dim xmlString As String = "<apiProtocol version=""1"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:noNamespaceSchemaLocation=""checkrequest.xsd""><checkRequest user=""uid"" password=""pid"" reference=""ref""><domain name=""test.com"" /></checkRequest></apiProtocol>" 'ConvertXmlToString(requestXmlDoc)
' Translate the passed message into ASCII and store it as a Byte array.
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(xmlString)
Dim client As TcpClient
Dim stream As NetworkStream
Try
Debug.Print("Connect to remote host:{0} port:{1} at:{2}", URL, PORT, Date.Now)
Debug.Print("Request: {0}", xmlString)
' Create a TcpClient.
' Note, for this client to work you need to have a TcpServer
' connected to the same address as specified by the server, port
' combination.
client = New TcpClient(URL, PORT)
client.ReceiveTimeout = 30000
' Get a client stream for reading and writing.
stream = client.GetStream()
' Send the message to the connected TcpServer.
stream.Write(data, 0, data.Length)
' Receive the TcpServer.response.
' Buffer to store the response bytes.
data = New [Byte](client.ReceiveBufferSize) {}
' Read the first batch of the TcpServer response bytes.
Dim bytes As Int32
bytes = stream.Read(data, 0, data.Length)
' Output the data received from the host and we have to cut tale
responseData = System.Text.Encoding.ASCII.GetString(data) ', 0, bytes
Debug.Print("Response: {0}", responseData)
stream.Close()
client.Close()
Catch e As ArgumentNullException
Debug.Print("ArgumentNullException: {0}", e)
Catch e As SocketException
Debug.Print("SocketException: {0}", e)
Catch e As Exception
Debug.Print("Connect Error: {0}", e)
End Try
' construct the response xml
Try
responseXmlDoc.LoadXml(responseData)
Catch ex As XmlException
Debug.Print("Connect Error: {0}", ex.Message)
End Try
Return responseXmlDoc
End Function
|