Jump to content

Help sending TCP request to XML processing server


Gordo54
 Share

Recommended Posts

Here is the story - I'll keep it as brief as possible.

My company has developed an "Application Server" that listens on port 85 by default for incoming requests. Depending on what is received, the server will invoke business logic to either execute the request on a database (for instance, add an order for a customer) or return a query from the database (lookup a customer address).

The server will accept SOAP requests as well as XML requests, however, the request must be pointed at the correct location depending on the type of request. Here's what I am trying to say:

If I want to send an XML request to add a customer <customer_add_request>some data</customer_add_request>, I would send the request to the server address and point it to processXML.slap (http://10.1.1.1:85/processXML.slap).

Is there a way to use the TCPSend function to send a request like this? I have written an XML file that I know works, I read the file then send it to the application server. The response I get from the server basically says that it is not reaching the correct destination (i.e. SOAP.slap, ProcessXML.slap, etc). I just need some way to "tack on" 'process.XML.slap' to the end of the address:port like noted above. Is this possible?

I have tried the following without success:

#include <GUIConstants.au3>
TCPStartUp()
Dim $szServerPC = @ComputerName
Dim $szIPADDRESS = TCPNameToIP($szServerPC)
Dim $nPORT = 85

Dim $ConnectedSocket = -1

$ConnectedSocket = TCPConnect($szIPADDRESS,$nPORT & "/processXML.slap")

MsgBox(0,"Test", $szIPADDRESS & ":" & $nPORT)
Dim $szData

$FileName = FileOpen("C:\request_1.xml",0)
$XMLData = FileRead ($FileName)

If @error Then
    MsgBox(4112,"Error","TCPConnect failed with WSA error: " & @error)
Else
    MsgBox(0, "XML Data", $XMLData)
    TCPSend($ConnectedSocket,$XMLData)
    Sleep(100)
    $Response = TCPRecv($ConnectedSocket,1024)
    MsgBox(0, "XML Response", $Response);
EndIf
TCPCloseSocket($ConnectedSocket)

Also:

#include <GUIConstants.au3>
TCPStartUp()
Dim $szServerPC = @ComputerName
Dim $szIPADDRESS = TCPNameToIP($szServerPC)
Dim $nPORT = "85/processXML.slap"

Dim $ConnectedSocket = -1

$ConnectedSocket = TCPConnect($szIPADDRESS,$nPORT)

MsgBox(0,"Test", $szIPADDRESS & ":" & $nPORT)
Dim $szData

$FileName = FileOpen("C:\request_1.xml",0)
$XMLData = FileRead ($FileName)

If @error Then
    MsgBox(4112,"Error","TCPConnect failed with WSA error: " & @error)
Else
    MsgBox(0, "XML Data", $XMLData)
    TCPSend($ConnectedSocket,$XMLData)
    Sleep(100)
    $Response = TCPRecv($ConnectedSocket,1024)
    MsgBox(0, "XML Response", $Response);
EndIf
TCPCloseSocket($ConnectedSocket)

Do any of you brilliant AutoIT coders have any ideas?

Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...