Kip Posted July 11, 2008 Posted July 11, 2008 Hi, I'm trying to connect to a xml-rpc server (for a game), but it just won't work. I don't see a reason why, I got all the headers, I have the right xml code (I think). Could someone take a look at this, please? expandcollapse popupDim $objHTTP Dim $strEnvelope Dim $strReturn Dim $objReturn Dim $dblTax Dim $strQuery Dim $value $sIP = "127.0.0.1" $iPort = 5001 ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $objHTTP = ObjCreate("Microsoft.XMLHTTP") $objReturn = ObjCreate("Msxml2.DOMdocument.3.0") ; Create the SOAP Envelope $strEnvelope = "<?xml version=""1.0""?>" & _ "<methodCall>" & _ "<methodName>system.listMethods</methodName>" & _ "</methodCall>" ; Set up to post to our local server $objHTTP.open ("post", "http://"&$sIP&":"&$iPort, False) ; Set a standard SOAP/ XML header for the content-type $objHTTP.setRequestHeader ("Content-Type", "text/xml") $objHTTP.setRequestHeader ("Content-length", StringLen($strEnvelope)) $objHTTP.setRequestHeader ("User-Agent", "GBX Remote 2") $objHTTP.setRequestHeader ("Host", $sIP) ; Set a header for the method to be called ;$objHTTP.setRequestHeader ("SOAPMethodName", "urn:myserver/soap:TaxCalculator#getsalestax") ConsoleWrite("Content of the Soap envelope : "& @CR & $strEnvelope & @CR & @CR) ; Make the SOAP call $objHTTP.send ($strEnvelope) ; Get the return envelope $strReturn = $objHTTP.responseText ; ConsoleWrite("Debug : "& $strReturn & @CR & @CR) ; Load the return envelope into a DOM $objReturn.loadXML ($strReturn) ConsoleWrite("Return of the SOAP Msg : " & @CR & $objReturn.XML & @CR & @CR) ; Query the return envelope ;$strQuery = "SOAP:Envelope/SOAP:Body/m:getsalestaxresponse/salestax" ;$dblTax = $objReturn.selectSingleNode($strQuery) ;$Soap = $objReturn.Text ;MsgBox(0,"SOAP Response","Return : " & $Soap) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Kip Posted July 12, 2008 Author Posted July 12, 2008 I made an other script, it uses tcp to connect to the server. When it connects, it receives this: (it receives something, jeeeh! ) 0x0B000000 GBXRemote 2I don't know what 0x0B000000 is supposed to mean? muttley It still doesn't work, after the stuff I received it doenst return anything, but i really send "system.listMethods" (which should return a list of all possible methods) Can somebody say what's wrong with it? Maybe a wrong http header? or xml. expandcollapse popupTCPStartup() Global $I_UNITED = 0 Global $I_FOREVER = 1 Global $GAME_MODE = $I_FOREVER Global $sIP = "127.0.0.1" Global $iPort = 5001 Global $hSocket = TCPConnect($sIP, $iPort) If not @error Then ConsoleWrite("<KSC> -Message- Connected to server."&@CRLF) Else ConsoleWrite("<KSC> -Message- Unable to connect to the server."&@CRLF) Terminate() EndIf Global $sHTTP = "POST /RPC2 HTTP/1.1" &@LF& _ "User-Agent: MyAgent" &@LF& _ "Host: "&$sIP &@LF& _ "Content-Type: text/xml" &@LF& _ "Content-length: %iLen%" &@CRLF Global $sXML = "<?xml version=""1.0""?>" & _ "<methodCall>" & _ "<methodName>%sMethod%</methodName>" & _ "<params>" & _ "</params>" & _ "</methodCall>" $sTempXML = StringReplace($sXML, "%sMethod%", "system.listMethods") $sTempHTTP = StringReplace($sHTTP, "%iLen%", StringLen($sTempXML)) TCPSend($hSocket,$sHTTP & $sTempXML) While 1 $sRecv = TCPRecv($hSocket, 1024) If $sRecv Then ConsoleWrite("<KSC> -Return- "&$sRecv&@CRLF) WEnd Func Terminate() While 1 Sleep(10000) WEnd EndFunc MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Kip Posted July 12, 2008 Author Posted July 12, 2008 bump? MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
ProgAndy Posted July 12, 2008 Posted July 12, 2008 Your header isn't correct. It should be separated with CRLF and end with double line muttley Global $sHTTP = "POST /RPC2 HTTP/1.1" &@CRLF& _ "User-Agent: MyAgent" &@CRLF& _ "Host: "&$sIP &@CRLF& _ "Content-Type: text/xml" &@CRLF& _ "Content-length: %iLen%" &@CRLF&@CRLF *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Kip Posted July 13, 2008 Author Posted July 13, 2008 Still doesn't send anything. muttley MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now