Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/29/2014 in all areas

  1. ptrex

    SOAP Example

    Simple SOAP Example For those who don't know what SOAP (Simple Object Access Protocol) is. In this SOAP example, you will learn what SOAP is, and how it uses XML to exchange information between applications. The next step will be, how to turn AU3 into a Web Services server. This is the SOAP CLIENT Dim $objHTTP Dim $strEnvelope Dim $strReturn Dim $objReturn Dim $dblTax Dim $strQuery Dim $value $value = InputBox("Testing", "Enter your new value here.", 10) ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $objHTTP = ObjCreate("Microsoft.XMLHTTP") $objReturn = ObjCreate("Msxml2.DOMdocument.3.0") ; Create the SOAP Envelope $strEnvelope = "<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">" & _ "<soap:header></soap:header>" & _ "<soap:body>" & _ "<m:getsalestax xmlns:m=""urn:myserver/soap:TaxCalculator"">" & _ "<salestotal>"&$value&"</salestotal>" & _ "</m:getsalestax>" & _ "</soap:body>" & _ "</soap:envelope>" ; Set up to post to our local server $objHTTP.open ("post", "http://localhost/soap.asp", False) ; Set a standard SOAP/ XML header for the content-type $objHTTP.setRequestHeader ("Content-Type", "text/xml") ; 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","The Sales Tax is : " & $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 This is the SOAP SERVER <% Dim oNode Set objReq = Server.CreateObject("Msxml2.DOMdocument.3.0") 'Load the request into XML DOM objReq.Load Request 'Query the DOM for the input parameter ' Remember: xpath is case sensitive. "SalesTotal" is not the same as "salestotal" strQuery = "SOAP:Envelope/SOAP:Body/m:getsalestax/salestotal" 'varSalesTotal = objReq.SelectSingleNode(strQuery).Text Set oNode = Nothing Set oNode = objReq.SelectSingleNode(strQuery) if not oNode is Nothing Then varSalesTotal = oNode.Text else 'handle the error - save the xml to a file so you can look at it varSalesTotal = objReq.Text end if 'Calculate the sales tax varSalesTax = varSalesTotal * 0.04 'Prepare the return envelope strTmp = _ "<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">" & _ "<soap:header></soap:header>" & _ "<soap:body>" & _ "<m:getsalestaxresponse xmlns:m=""urn:myserver/soap:Taxcalc"">" & _ "<salestax>" & varSalesTax & "</salestax>" & _ "</m:getsalestaxresponse>" & _ "</soap:body>" & _ "</soap:envelope>" 'Write the return envelope Response.Write strTmp %> Save the SOAP SERVER as SOAP.asp and put it in the root of your IIS server. Run the client and see what happenes. Enjoy !! Regards ptrex
    1 point
  2. Mat

    Fraction

    I don't know who's still at school or university here, but if you are chances are you are familiar with the current casio calculators, which give you answers in terms of fractions, square roots, and pi when it is reasonable to do so. For example, sin(pi/3) = sqrt(3)/2. With those limits, you could define a new kind of "fraction" that had 4 components: A/B * sqrt© * pi^D, Of course in that vein you can keep adding variables and layers of complexity ad nauseam.
    1 point
  3. LWC

    UPnP Port Forwarding Final

    In most examples, the adding process is set to "true" and not to "false". Plus not all routers support UPnP through Windows's COM objects. So if anything, it should be like this: $port = InputBox("Portnumber to forward to this pc", "Port:") $oRouter = ObjCreate("HNetCfg.NATUPnP") $oPortList = $oRouter.StaticPortMappingCollection if isobj($oportlist) Then $oPortList.Add($port, "TCP", $port, @IPAddress1, True, "") $oPortList.Add($port, "UDP", $port, @IPAddress1, True, "") Else MsgBox(16, "Error", "Could not create a UPnP object") endif Which brings us to the real final question: does anyone have a solution to the "else" cases? In other words, does anyone have a code to enable ports in such routers using SOAP (without using external third parties)? This may help.
    1 point
×
×
  • Create New...