COM (Vb/vba/script) invokes the WCF service four using service tokens: Using a configuration file

Source: Internet
Author: User
Tags wsdl

These days friends and classmates say he encountered a problem when COM invoked the WCF service using service tokens, that is, the SOAP message he returned was greater than the default value of the Wshttpbinding of 65536, raising the call error. You need to change the maxreceivedmessagesize to a value that can hold large message content. The default wshttpbinding is used in the previous three articles, so there is no such problem. Now you need to change the default value. Naturally, you need to increase the configuration to achieve your goal. The key question at the moment is: Is it possible for Vb/vba/script to use the configuration file? If so, how do you get Vb,vba script to use the bindings defined in the configuration file?

After a multi-party search and exploration attempt, the solution was finally found, as long as the configuration file was placed in the same directory as the host file, and the name of the profile was changed to the host file with the same name (including the extension) Plus. config, you can let Vb/vba/script To invoke the WCF service using bindings defined in the configuration file. If the VBS file (VB Script), because the implementation of the VBS file is Cscript.exe or Wscript.exe, by default, our system is using Wscript.exe to execute, at this time you can match The file is placed under the system32 of the system directory, named Wscript.exe.config.

If it's a VBA macro, it depends on Word or Excel, or something else. Because of different types, their profile name is not the same. If it is word, then the profile name should be WINWORD.EXE.config and, if it is Excel, the configuration file name should be: Excel.exe.config. Other types, and so on.

If it is VB program, if our program name is Test.exe, then the configuration file name is called Test.exe.config.

It should be noted, however, that if COM (vb/vba/script) uses the service tag to invoke the WCF service using a configuration file, we can only use the typed contract, not the MEX contract and the WSDL contract (specifically how to use the typed contract, the MEX contract, the WSDL contract, please Refer to my previous article. COM (Vb/vba/script) invokes one of the WCF services using a service token use a typed contract, COM (vb/vba/script) invoke a WCF service with a service token use MEX contract, COM (vb/vba/script)  Using service tokens to invoke the third WCF service using a WSDL contract, this may be related to the tag string, and careful students may find that the binding in the typed tag string and the configuration in. NET are the same, while the binding in the Mex and WSDL tag strings are fixed. To make it clearer, the following example invokes WCF with a typed contract service token in the VBS, because the WCF service side of this series is essentially the same, but this time Since we made partial changes to the Service1.svc.cs file on the server for the purpose of making a message that returns more than 65,536 characters, the contents of the changed file are as follows: using System;

Using System.Collections.Generic;
Using System.Linq;
Using System.Runtime.Serialization;
Using System.ServiceModel;
Using System.Text;
Namespace Wcfservicemoniker
{public
class Service1:iservice1
{public
string SayHello (string Yourwords)
{return
string. Format ("Hello world! You entered: {0}{1} ", Yourwords,new string (' A ', 65536));}}

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.