Directly use XML for SOAP requests

Source: Internet
Author: User
' Preserve the local variable of the attribute value
Private Mvarserverurl As   String   ' Local Replication

Public   Property   Let Serverurl (byval vdata As   String )
' Used to assign a value to a property, which is on the left of the value assignment statement.
' Syntax: X. serverurl = 5
Mvarserverurl = Vdata
End Property

Public   Property   Get Serverurl () As   String
' Used to retrieve attribute values, on the right of the value assignment statement.
' Syntax: Debug. Print X. serverurl
Serverurl = Mvarserverurl
End Property

Public   Function Executecommandwithreturn (byval command As   String ) As   String
Dim Safestring As   String ' Authentication Code
Dim Strxml As   String ' Soap Query

' On Error goto errs:
On   Error   Resume   Next


Safestring =   Lcase ( Replace ( " 592672-016767-2cc4f321-0e348af1-ab52ff57-e07a " , " - " , "" ))
' Command = Replace (command, "", "& nbsp ;")
' Command = Replace (command, "'", "& apos ;")
' Command = Replace (command, "," & quot ;")
' Command = Replace (command, "<", "& lt ;")
' Command = Replace (command, ">", "& RT ;")
' Command = Replace (command, "&", "& amp ;")

Strxml = Strxml &   " <? XML version = "" 1.0 "" encoding = "" UTF-8 ""?> "   & Vbcrlf
Strxml = Strxml &   " <Soap: envelope xmlns: xsi = "" http://www.w3.org/2001/XMLSchema-instance "" xmlns: XSD = "" http://www.w3.org/2001/XMLSchema "" xmlns: Soap = "" http://schemas.xmlsoap.org/soap/envelope/ ""> "   & Vbcrlf
Strxml = Strxml &   " <Soap: Body> "   & Vbcrlf
Strxml = Strxml &   " <Executecommandwithreturn xmlns = "" http://tempuri.org/GPSService/Data ""> "   & Vbcrlf
Strxml = Strxml &   " <Safecode> "   & Safestring &   " </Safecode> "   & Vbcrlf
Strxml = Strxml &   " <Commandtext> "   & Command &   " </Commandtext> "   & Vbcrlf
Strxml = Strxml &   " </Executecommandwithreturn> "   & Vbcrlf
Strxml = Strxml &   " </Soap: Body> "   & Vbcrlf
Strxml = Strxml &   " </Soap: envelope> "

' Defines an xml http request object for sending requests
Dim Soaphttp As   New MSXML. XMLHttpRequest

' Define an XML Document Object and convert the handwritten or accepted XML content into an XML object.
Dim Soapxml As   New MSXML. domdocument

' Converts a handwritten soap string to an XML object.
Soapxml. loadxml strxml

' Sends a post message to a specified URL.
Soaphttp. Open " Post " , Mvarserverurl &   "" , False
Soaphttp. setRequestHeader " Content-Type " , " Text/XML; charset = UTF-8 "
' Soaphttp. setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client protocol 1.1.4322.2300 )"
Soaphttp. setRequestHeader " Soapaction " , " Http://tempuri.org/GPSService/Data/ExecuteCommandWithReturn "
Soaphttp. Send (strxml)

While Soaphttp. readystate <>   4 ' Wait for processing to complete
Wend

' Returned XML Information
Dim Strreturn As   String
' Debug. Print soaphttp. responsetext
Dim Xmlreturn As MSXML. domdocument
Set Xmlreturn = Soaphttp. responsexml

Executecommandwithreturn = Xmlreturn. childnodes ( 1 ). Text
Set Xmlreturn =   Nothing
Set Soapxml =   Nothing
Set Soaphttp =   Nothing
Exit   Function
Errs:
Msgbox Err. Description
Debug. Print err. Description
End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.