Use ASP to call. Net XML Web Services

Source: Internet
Author: User
Tags net xml

(Can I actually use this method to call any XML Web Services? Answer)
I am working on a Web Service recently. I will write a document. To facilitate ASP users to use our services, I searched the internet for a long time and found that there are roughly two ways to call. Net XML Web Services through ASP.
1. Use soap Toolkit 3.0
2. Use XMLHTTP
Let me write a summary, so that if you encounter such a problem in the future, if you search for my page, you can immediately implement your own solution.
1. Use soap Toolkit 3.0
If the website is built on a server that you can control, you can install soap Toolkit 3.0. Soap toolkit is a web services solution provided by Microsoft. You can download it from the following URL. It is free of charge.
Http://www.microsoft.com/downloads/details.aspx? Familyid = c943c0dd-ceec-4088-9753-86f052ec8450 & displaylang = en
After the download, install it.
I wrote ASP just a few years ago, and now I have forgotten it. So, I will write down the basic operations and give a specific example below, you can view the user guide installed with the soap toolkit, which contains a special example.
The basic process is
'Create a mssoap. soapclient30 object.
Set SC = Createobject ("mssoap. soapclient30 ")
'Set serverhttprequest to true.
SC. clientproperty ("serverhttprequest") = true
'Call the mssoapinit method to reference web services.
SC. mssoapinit "http: // 192.168.10.199/webservice1/service1.asmx? WSDL ","","",""
'Start to call the methods provided by Web Services
MSG = SC. helloie ("notus", "Kerry ")
MSG receives the returned value and performs the next step .. I only tested the most basic string type and received other complex types. For more information, see user guide.
Mssoapinit accepts four parameters. The first one is the WSDL address of Web Services. (The URL of the WSDL file that describes the services offered by the server or a string containing the WSDL document.) the other three are optional.
The soap toolkit User Guide provides more examples and detailed instructions.
The advantage of using soap toolkit is obvious, that is, it can easily use various web services methods, and it also has good support. the disadvantage is obvious, that is, the installation is required. It is estimated that most people will not use it.

2. use XMLHTTP
set objhttp = server. createobject ("msxml2.xmlhttp")
'note that the WSDL address is not specified here, but the Web Services method to be used
strwebserviceurl = "http: // 192.168.10.199/webservice1/service1.asmx/helloie "
'set parameters and their values. This is a bit of a hassle, the final structure is a string similar to "msg1 & msg2 & msg3.
I = "notus red"
AC = "loves"
strrequest = "MSG =" + I + "& Action =" + AC
objhttp. open "Post", strwebserviceurl, false
'setting this Content-Type is very important
objhttp. setRequestHeader "Content-Type", "application/X-WWW-form-urlencoded"
'send data to Web sercices
objhttp. send (strrequest)
'receive returned data
set xmldoc = server. createobject ("MSXML. domdocument ")
Bok = xmldoc. load (objhttp. responsexml)
'process the data
MSG = xmldoc. XML
If Bok is true, the returned data is successfully received.
as you can see here, we all understand that this is actually directly post the data and then retrieve the returned data. it seems a bit Ajax-like.
This is said to require the server to support using post/get to access web services. that is to say, in the web. add





This is a common method, there is no need to install anything, but it is troublesome.

What are the effects of these two methods? I haven't launched the verification yet, but I can perform a local test. After a few days of online testing, if any problem occurs, I will come back to supplement it.

 

Related Article

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.