COM (Vb/vba/script) invoking the WCF service using service tokens use a WSDL contract

Source: Internet
Author: User
Tags wsdl

We introduced the service tag using the MEX contract to invoke the WCF service in COM in such a way that it is convenient to obtain metadata dynamically through the MEX endpoint, but sometimes the metadata of the service may contain sensitive information about the application that a malicious user can exploit. This means that some services may not publish metadata information through Mex for security reasons. If oh, some services do not publish metadata information, with typing is more cumbersome, in this case how do we invoke WCF services in COM? At this point we can use the WSDL contract to invoke the WCF service, which is similar to the use of MEX, and does not require type registration, information is obtained dynamically, but there is a bad place to use other means to get the WSDL description of the service. Well, let's start with the first step: Create a WCF service this is exactly the same as the previous one, see COM (vb/vba/script) using the service tag to invoke one of the WCF services using a typed contract, if you've ever tested the previous article with the corresponding test, You can use the services that have been built directly. Step two: Invoke the WCF service in script

1: The following is the creation of our script file, we named Callwcfservice_wsdl.vbs, the contents are 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 would be truncated, but WScript.Echo would not. 9 ' wscript.echo xmlhttp.responsetext wsdlstr=xmlhttp.responsetext 12mexMonikerString = ' service:address= ' http:// Localhost/wcfservicemoniker/service1.svc ' "13mexMonikerString = mexmonikerstring +", wsdl= ' "& Wsdlstr &" "14m
exmonikerstring = mexmonikerstring + ", Binding=wshttpbinding_iservice1, bindingnamespace= ' http://tempuri.org/'" 15mexMonikerString = mexmonikerstring + ", Contract=iservice1, contractnamespace= ' http://tempuri.org/'" "Create th E Service Moniker Object 18Set Mexservicemoniker = GetObject (mexmonikerstring) ' call ' service operations using th E Moniker Object 21wscript.echo Mexservicemoniker.sayhello ("I am Lazybee, my blog is http://lazybee.cnblogs.com/") 23Set Mexservicemon Iker = Nothing 24Set xmlhttp=nothing 

Note: In our service tag string, there are four parts of the service address, WSDL, bindings and namespaces, service contracts, and namespaces. For information on how to obtain service addresses, bindings and namespaces, service contracts, and namespaces see the previous article COM (vb/vba/script) invoking the WCF service with service tokens the second step of using the MEX contract

4 After you save, double-click to run, you can see the results of the operation:

Source: http://lazybee.cnblogs.com

This article supporting source code: http://www.bianceng.net/dotnet/201212/757.htm

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.