Service interfaces are often called across platforms and technologies. When using non-. NET technology (such as ASP and VB6) to call a WCF Service interface, you can only use the com method. There are usually three methods.
1. Use the soap object in the soap SDK
2. Use the httprequest object
3. Use the COM interface of WCF
The third method is relatively simple and recommended for personal use. The third call method is described below.
To meet the COM object call requirements,. Net framework3.5sp1 registers the WCF proxy interface with the COM component object, which is the moniker object. We can use the OLE com Viewer tool to find it.
You can use the GetObject method to obtain this object. ASPCodeDemonstrate how to obtain a moniker object and call it
1 < %
2 Response. Write " Coding started! "
3 Response. Write " </BR> "
4
5 Dim Mexico monikerstring
6 Dim Mexservicemoniker
7
8 Mexico monikerstring = " Service: Mexico address = http://xxxxx.aaaa.com: 81/wcfservice1/service1.svc? WSDL "
9 Mexico monikerstring = Mexico monikerstring + " Address = http://xxxx.aaaa.com: 81/wcfservice1/service1.svc/ "
10 Mexico monikerstring = Mexico monikerstring + " , Binding = wshttpbinding_iservice1, bindingnamespace = http://tempuri.org/ "
11 Mexico monikerstring = Mexico monikerstring + " , Contract = iservice1, contractnamespace = http://tempuri.org/ "
12
13 Set Mexservicemoniker = GetObject (Mexmonikerstring)
14
15 Mexico servicemoniker. channelcredentials. setusernamecredential " Wcfcaller " , " Wcfcaller "
16 Response. Write mexservicemoniker. Echo ( " Sss " )
17
18
19 Set Mexservicemoniker = Nothing
20 % >
The parameters used to call the GetObject method include:
1. Metadata Exchange address.
The WSDL file address of the WCF interface.
2. Service address
The service address of the WCF interface, that is, the URI of the SVC file.
3. Binding name
WSDL In the WSDL file: Binding configuration section, name attribute
4. Service Contract name
WSDL In the WSDL file: porttype configuration section, name attribute
If the above configuration is correct and the call is still wrong, it is likely that your service interface contains parameters or return values of the object type, and the data cannot be non.. NET environment. Therefore, if your WCF interface needs to be called across technologies, you must use the interface parameters and return values of the simple data type.