COM (Vb/VBA/script) uses service tags to call the WCF Service 3. Use the WSDL contract

Source: Internet
Author: User

COM (Vb/VBA/script)Call with service tagWCFService

Usage 3WSDLContract

Lazybee(Http://lazybee.cnblogs.com)

We have introduced how to use MEX The service of the contract is marked in Com Calling WCF Service. MEX The endpoint dynamically acquires metadata, which is convenient to use. However, sometimes the metadata of the service may contain information about the application that malicious users can use.ProgramThat is to say, some services may not pass MEX Publish metadata information. If some services do not publish metadata information, it is difficult to use data types. Com Calling WCF What about services? In this case, we can use WSDL Contract to carry out WCF This method is used to call a service. MEX Similarly, you do not need to register the type, and the information is obtained dynamically. However, a bad thing is that you need to use other methods to obtain the service. WSDL Description. Okay. Let's get started.

 

Step 1: CreateWCFService

This is exactly the same as the previous article. For more information, see COM (Vb/VBA/script)Call with service tagWCFOne service uses a typed contract The first stepArticleAfter testing, you can directly use the created service.

 

Step 2:ScriptCallingWCFService

1:ScriptFile, we name itCallwcfservice_wsdl.vbs,The content is as follows:

1 ' ---------------------------------------------------------------
2 ' WSDL service moniker example
3 ' ---------------------------------------------------------------
4
5   Set XMLHTTP = Createobject ( " Msxml2.xmlhttp " )
6   Call XMLHTTP. Open ( " Get " , " Http: // localhost/wcfservicemoniker/service1.svc? WSDL " , False )
7 XMLHTTP. Send
8   ' Msgbox message will be truncated, but wscript. Echo will not.
9   ' Wscript. Echo XMLHTTP. responsetext
10 Wsdlstr = XMLHTTP. responsetext
11
12 Mexico monikerstring =   " Service: Address = 'HTTP: // localhost/wcfservicemoniker/service1.svc' "
13 Mexico monikerstring = Mexico monikerstring +   " , WSDL =' "   & Wsdlstr &   " ' "
14 Mexico monikerstring = Mexico monikerstring +   " , Binding = wshttpbinding_iservice1, bindingnamespace = 'HTTP: // tempuri.org /' "
15 Mexico monikerstring = Mexico monikerstring +   " , Contract = iservice1, contractnamespace = 'HTTP: // tempuri.org /' "
16
17 ' Create the service moniker object
18 Set Mexservicemoniker =   GetObject (Mexmonikerstring)
19
20 ' Call the service operations using the moniker object
21 Wscript. Echo mexservicemoniker. sayhello ( " I am lazybee, my blog is http://lazybee.cnblogs.com/ " )
22
23 Set Mexservicemoniker =   Nothing
24 Set XMLHTTP = Nothing
25

 

Note: The service tag string contains the service address, WSDL , Binding and namespace, service contract, and namespace. For more information about how to obtain service addresses, bindings and namespaces, service contracts, and namespaces, see the previous article. COM (Vb/VBA/script) call with service tags WCF service 2 usage Mex contract Step 2

4After saving it, double-click it to run it. Then you can see the running result:



the Source Code in this article is: http://files.cnblogs.com/LazyBee/CallWCFService_wsdl.zip

(For reprint, please indicate the source:Http://lazybee.cnblogs.com)

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.