Call Web Service from a VC++ 6.0 Client
2005-02-28 13:49
489 查看
What you need :
Microsoft SOAP toolkit 3.0 with Microsoft XML 2.0 included.
Microsoft Visual C++ 6.0, we use it create client application.
Microsoft Visual Studio.NET, we use VC# to create web service.
VC code :
function ToggleSourceCodeRegion(regionNumber)
{
var divRegion = document.getElementById('region' + regionNumber);
var divRegionBlock = document.getElementById('regionBlock' + regionNumber);
if (divRegion.style.display == 'inline')
{
divRegion.style.display = 'none';
divRegionBlock.style.display = 'inline';
}
else
{
divRegion.style.display = 'inline';
divRegionBlock.style.display = 'none';
}
}
C# code :
Microsoft SOAP toolkit 3.0 with Microsoft XML 2.0 included.
Microsoft Visual C++ 6.0, we use it create client application.
Microsoft Visual Studio.NET, we use VC# to create web service.
VC code :
function ToggleSourceCodeRegion(regionNumber)
{
var divRegion = document.getElementById('region' + regionNumber);
var divRegionBlock = document.getElementById('regionBlock' + regionNumber);
if (divRegion.style.display == 'inline')
{
divRegion.style.display = 'none';
divRegionBlock.style.display = 'inline';
}
else
{
divRegion.style.display = 'inline';
divRegionBlock.style.display = 'none';
}
}
1#include "stdafx.h" 2#include <windows.h> 3#include <stdio.h> 4#import "msxml4.dll" 5using namespace MSXML2; 6#import "C:/Program Files/Common Files/MSSoap/Binaries/mssoap30.dll" / 7 exclude("IStream", "IErrorInfo", "ISequentialStream", "_LARGE_INTEGER", / 8 "_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME") 9using namespace MSSOAPLib30; 10 11bool SayHello(char *UserName) 12{ 13 ISoapSerializerPtr Serializer; 14 ISoapReaderPtr Reader; 15 ISoapConnectorPtr Connector; 16 // Connect to the service. 17 Connector.CreateInstance(__uuidof(HttpConnector30)); 18 Connector->Property["EndPointURL"] = "http://localhost/WebServices/SayHello/SayHello.asmx"; 19 Connector->Connect(); 20 21 // Begin the message. 22 Connector->Property["SoapAction"] = "http://tempuri.org/SayHelloToMe"; 23 Connector->BeginMessage(); 24 25 // Create the SoapSerializer object. 26 Serializer.CreateInstance(__uuidof(SoapSerializer30)); 27 28 // Connect the serializer object to the input stream of the connector object. 29 Serializer->Init(_variant_t((IUnknown*)Connector->InputStream)); 30 31 // Build the SOAP Message. 32 33 Serializer->StartEnvelope("", "", ""); 34 Serializer->StartBody(""); 35//Remember to set DefaultNamespace, or an exception will show before you. 36//Microsoft SOAP toolkit providered code has no this line ! 37//it works not 38 Serializer->SoapDefaultNamespace("http://tempuri.org/"); 39 Serializer->StartElement("SayHelloToMe","","",""); 40 Serializer->StartElement("UserName","","",""); 41 Serializer->WriteString(UserName); 42 Serializer->EndElement(); 43 Serializer->EndElement(); 44 Serializer->EndBody(); 45 Serializer->EndEnvelope(); 46 47 // Send the message to the XML Web service. 48 Connector->EndMessage(); 49 50 // Read the response. 51 Reader.CreateInstance(__uuidof(SoapReader30)); 52 53 // Connect the reader to the output stream of the connector object. 54 Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), ""); 55 56 // Display the result. 57 printf("Answer: %s/n", (const char*)Reader->RpcResult->text); 58 if(Reader->GetFault() != NULL) 59 printf("Fault : %s/n", (const char *)Reader->GetFault()->text); 60 return false; 61} 62 63int main(int argc, char* argv[]) 64{ 65 CoInitialize(NULL); 66 SayHello("dtianx@hotmail.com"); 67 CoUninitialize(); 68 return 0; 69} 70
C# code :
1[WebMethod] 2string SayHelloToMe(string UserName) 3{ 4 return "Hello ," + UserName; 5}
相关文章推荐
- How To: Call a Java EE Web Service from a .Net Client
- java client call .net web service
- SharePoint 2010 WebService system cannot find the file specified. (Exception from HRESULT: 0x80070002
- Invoke WCF service from Java Client with Authentication (X.509 Certificate) Java 客户端调用WCF服务 需要安全验证
- Invoking Webservice from PL/SQL (UTL_DBWS&UTL_HTTP)
- Using UTL_DBWS to Make a Database 11g Callout to a Document Style Web Service
- Creation of an Axis Web Service and a gSOAP client
- android - How to make a phone call from webview
- 解决Java call php web webService 中文参数乱码 终极解决方法
- Webservice error, "The test form is only available for requests from the local machine"
- Web API: Client: Call a Web API from a .net client
- Axis2调用webservice Client
- Non-blocking Web Service Client
- mfc call c# webservice method
- Call PDF to Vector Converter Command Line from C#, ASP, etc. web program languages
- MyEclipse 下开发Java webService 和 Java webClient 的一个完整回调列子
- 如何用JavaScript调用Web服务——callService/useService
- Temperature Convert:ATL Server Webservice and Client
- [WASM] Call a JavaScript Function from WebAssembly
- Web Service & Client