Http://blog.csdn.net/goodym/archive/2004/08/03/HowToUseWebservice.aspx
HTML webpage callMethod
<Form target = "_ blank" Action = 'HTTP: // www.ydcom.net/service/s_comm.asmx/getczid' method = "Post"> "〉
<Table cellspacing = "0" cellpadding = "4" frame = "box" bordercolor = "# dcdcdc" rules = "NONE" style = "border-collapse: collapse;"> ;"〉
<Tr> 〉
<TD class = "frmheader" background = "# dcdcdc" style = "border-Right: 2px solid white;"> parameter </TD> 〉
<TD class = "frmheader" background = "# dcdcdc"> value </TD> 〉
</Tr> 〉
<Tr> 〉
<TD class = "frmtext" style = "color: #000000; font-weight: normal;"> stypenum: </TD> 〉
<TD> <input class = "frminput" type = "text" size = "50" name = "stypenum"> </TD> 〉
</Tr> 〉
<Tr> 〉
<TD> </TD> 〉
<TD align = "right"> <input type = "Submit" value = "call" class = "button"> </TD> 〉
</Tr> 〉
</Table> 〉
</Form> 〉
Example: how to call a service to generate 18-bit key values
Related documents:Use Vbscript to call Web Services
ASP call method (soap method)
Dim URL, XMLHTTP, Dom, node, xmldoc
'Construct different SOAP requests based on different methods on the WebService test page.
Soaprequest =" "&_
" "Xmlns: XSD =" & CHR (34) & "http://www.w3.org/2001/XMLSchema" & CHR (34 )&""&_
"Xmlns: Soap =" & CHR (34) & "http://schemas.xmlsoap.org/soap/envelope/" & CHR (34) & "> "&_
""&_
" "&_
" 311 "&_
" "&_
""&_
""
Url = "http://www.ydcom.net/service/S_COMM.asmx? Methodname = getczid"
Set xmldoc = server. Createobject ("MSXML. domdocument ")
Xmldoc. loadxml (soaprequest)
Set XMLHTTP = server. Createobject ("msxml2.xmlhttp ")
XMLHTTP. Open "Post", URL, false
XMLHTTP. setRequestHeader "Content-Type", "text/XML; charset = UTF-8"
XMLHTTP. setRequestHeader "soapaction", "http://www.ydcom.net/service/SrvCOMM/S_COMM/GetCZID"
XMLHTTP. setRequestHeader "Content-Length", Len (soaprequest)
XMLHTTP. Send (xmldoc)
If xml http. Status = 200 then
Xmldoc. Load (XMLHTTP. responsexml)
Response. Write XMLHTTP. Status &"
"
Response. Write XMLHTTP. statustext &"
The execution result is :"
Response. Write xmldoc. getelementsbytagname ("getczidresult") (0). Text
Else
Response. Write XMLHTTP. Status &"
"
Response. Write XMLHTTP. statustext
End if
%>
Example: how to use ASP to call the service to generate 18-bit key value ASP source file code
Note: In general, the list page of WebService is used to construct different soaprequests. Then,
Retrieve the returned value xmldoc. getelementsbytagname from the returned xmldoc
ASP call method (HTTP)
Set objhttp = server. Createobject ("msxml2.xmlhttp ")
Set xmldoc = server. Createobject ("MSXML. domdocument ")
Strwebserviceurl = "http://www.ydcom.net/service/S_COMM.asmx/GetCZID"
'Set parameters and their values
Strrequest = "stypenum = 311"
Objhttp. Open "Post", strwebserviceurl, false
'Setting this Content-Type is very important.
Objhttp. setRequestHeader "Content-Type", "application/X-WWW-form-urlencoded"
Objhttp. setRequestHeader ("Content-Length: 30 ")
Objhttp. Send (strrequest)
Bok = xmldoc. Load (objhttp. responsexml)
'Look at the status value
If objhttp. Status = 200 then
Xmlstr = xmldoc. xml
Response. Write xmlstr
Else
Response. Write objhttp. statu &"
"
Response. Write objhttp. statustext
End if
%>
Example: how to use ASP to call the service to generate 18-bit key value ASP source file code
Call methods in VB6
Dim strxml as string
Dim STR as string
STR = text2.text
'Define a SOAP message
Strxml =" 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/'> "& STR &
" "
'Define an HTTP object and send a post message to the server.
Dim h as msxml2.serverxmlhttp40
'Define an XML Document Object and convert the handwritten or accepted XML content into an XML Object
Dim X as msxml2.domdocument40
'Initialize the XML Object
Set x = new msxml2.domdocument40
'Convert a handwritten soap string to an XML Object
X. loadxml strxml
'Initialize the HTTP object
Set H = new msxml2.serverxmlhttp40
'Send post message to the specified URL
H. Open "Post", "http: // localhost/testwebservice/service1.asmx", false
H. setRequestHeader "Content-Type", "text/XML"
H. Send (strxml)
While H. readystate <> 4
Wend
'Display returned XML Information
Text1.text = H. responsetext
'Parse the returned XML Information and display the returned value.
Set x = new msxml2.domdocument40
X. loadxml text1.text
Text1.text = x. childnodes (1). Text
Call methods in VB. NET
1, first add web reference, address: http://www.ydcom.net/service/s_comm.asmx
2. Definition: dim scom as new net. ydcom. www. s_comm
3. Call: dim strczid as string = scomm. getczid ("313 ")
Example: how to use VB. NET to call the service to generate 18-bit key value VB. NET source file code
Call methods in Pb. Net (pb9)
Soapconnection Conn
Test_wsservice1soap scom
Long rval
// String str_endpoint
// Str_endpoint = "http://www.ydcom.net/service/s_comm.asmx? WSDL"
Conn = create soapconnection
Rval = conn. createinstance (scom, "test_wsservice1soap ")
Sle_1.text = scom. getczid ("313 "))
Destroy Conn